# |
Jul 9th 2019, 08:17 |
neon1024 |
`{% elseif columnData.field == 'id' %}` |
# |
Jul 9th 2019, 08:16 |
neon1024 |
I’d like to wrap my numbers in `->Number->format()` but not my `id` field |
# |
Jul 9th 2019, 08:16 |
neon1024 |
How do I detect the `id` field in a bake theme using Twig? |
# |
Jul 9th 2019, 08:10 |
kgb.acct.personal |
I'll keep this in mind |
# |
Jul 9th 2019, 08:07 |
kgb.acct.personal |
Thanks for the tip guys :+1: |
# |
Jul 9th 2019, 08:05 |
admad |
statics are evil |
# |
Jul 9th 2019, 08:05 |
challgren |
@kgb.acct.personal my guess would be for testing mocking |
# |
Jul 9th 2019, 08:05 |
kgb.acct.personal |
TL;DR please? |
# |
Jul 9th 2019, 08:05 |
kgb.acct.personal |
> No.. don't use TableRegistry anymore Why tho? |
# |
Jul 9th 2019, 08:05 |
admad |
guess we havent gotten around to updating all references in cookbook |
# |
Jul 9th 2019, 08:04 |
kgb.acct.personal |
I'll keep in mind to use `loadModel` wherever possible |
# |
Jul 9th 2019, 08:04 |
kgb.acct.personal |
What a twist. `TableRegistry` is often found on the cookbook. |
# |
Jul 9th 2019, 08:03 |
neon1024 |
Oh right |
# |
Jul 9th 2019, 08:03 |
admad |
@neon1024 and then jumped shipped :P j/k. He's employed elsewhere now. |
# |
Jul 9th 2019, 08:01 |
admad |
forget `TableRegistry` even exists |
# |
Jul 9th 2019, 08:01 |
kgb.acct.personal |
Woah. Wait |
# |
Jul 9th 2019, 08:01 |
neon1024 |
@savant gathered them all |
# |
Jul 9th 2019, 08:00 |
neon1024 |
@challgren I’m not sure it is, but a lot of the core team do work there |
# |
Jul 9th 2019, 08:00 |
admad |
use `$this->loadModel()` wherever ever possible. Else use `TableLocatorTrait` in the class the use `$this->getTableLocator()->get()` |
# |
Jul 9th 2019, 08:00 |
challgren |
Eg bad to use in entities |
# |
Jul 9th 2019, 08:00 |
challgren |
But I always use ModelAwareTrait unless I got serialization issues |
# |
Jul 9th 2019, 07:59 |
mehov |
Same here, same here :slightly_smiling_face: |
# |
Jul 9th 2019, 07:59 |
challgren |
He’s the expert! I will always defer to @admad |
# |
Jul 9th 2019, 07:59 |
mehov |
@challgren I like how changed your opinion that fast :) |
# |
Jul 9th 2019, 07:58 |
challgren |
Do what admad says! |
# |
Jul 9th 2019, 07:58 |
admad |
No.. don't use TableRegistry anymore |
# |
Jul 9th 2019, 07:57 |
mehov |
Been doing that too, yep |
# |
Jul 9th 2019, 07:57 |
challgren |
`TableRegistry::getTableLocator()->get('Articles')` would be the new method |
# |
Jul 9th 2019, 07:57 |
mehov |
I need to use a model in a controller. I was performing the tableregistry/tablelocator trickery until one of those got deprecated so I had to research and redo. Using the good old loadModel since then. I'm not the OP though |
# |
Jul 9th 2019, 07:55 |
challgren |
Well whats your use case? And is the model your trying to access in any way related to an already loaded model? |
# |
Jul 9th 2019, 07:51 |
mehov |
The point still stands though, or you think it doesn't? |
# |
Jul 9th 2019, 07:51 |
challgren |
Give or take a year! |
# |
Jul 9th 2019, 07:51 |
mehov |
@challgren 4, actually :) |
# |
Jul 9th 2019, 07:50 |
mehov |
https://stackoverflow.com/questions/50518521/deprecation-of-tableregistryget#comment88054262_50518521 |
# |
Jul 9th 2019, 07:50 |
challgren |
That was written 3 years ago FYI |
# |
Jul 9th 2019, 07:49 |
mehov |
https://stackoverflow.com/questions/29578825/which-approach-is-best-to-get-instance-of-a-table-in-cakephp-3-0 |
# |
Jul 9th 2019, 07:49 |
challgren |
But avoid using loadModel in Entities causes issues with serialization |
# |
Jul 9th 2019, 07:49 |
challgren |
loadModel is also part of ModelAwareTrait so it can be used in a lot of places |
# |
Jul 9th 2019, 07:48 |
mehov |
As far as I understand, one should use loadModel where possible, and TableLocator in other cases |
# |
Jul 9th 2019, 07:40 |
kgb.acct.personal |
Sup. When do I use loadModel() and TableLocator::get()? |
# |
Jul 9th 2019, 07:39 |
challgren |
Seatgeek is written in Cake if I recall |