# |
Mar 6th 2018, 16:01 |
neon1024 |
Has doesn’t check emptyness |
# |
Mar 6th 2018, 16:01 |
neon1024 |
Which if you’re a designer in a template, seems very confusing |
# |
Mar 6th 2018, 16:01 |
dereuromark |
why not ->has() then?^^ |
# |
Mar 6th 2018, 16:01 |
neon1024 |
I end up with `if (!empty($catalog->get('content') andand !empty($catalog->get('content')->get('adverts')) { // Output advert };` |
# |
Mar 6th 2018, 16:00 |
dereuromark |
with nesting it must always use latter one of course! |
# |
Mar 6th 2018, 16:00 |
dereuromark |
well, there are two use cases: get() and I dont care about existence - and get() but make sure it exists |
# |
Mar 6th 2018, 15:59 |
neon1024 |
`$catalog->get('content')->get('adverts')` for example, could throw two fatals |
# |
Mar 6th 2018, 15:59 |
neon1024 |
The fatal really disrupts my templates as I have to put lots of state checking in. Especially so with nested associations |
# |
Mar 6th 2018, 15:59 |
neon1024 |
As it keeps away the magic, but allows developers like myself to allow the return of null |
# |
Mar 6th 2018, 15:58 |
neon1024 |
That my friend is a super idea! |
# |
Mar 6th 2018, 15:58 |
dereuromark |
neon: maybe get() should have a 2nd default param and if not null (empty string) it would return that instead. alternative: getIfExists() as soft version |
# |
Mar 6th 2018, 15:58 |
flavius |
nevermind, those are ORM |
# |
Mar 6th 2018, 15:57 |
flavius |
i use the proprieties, `$article->id` and such, never used entity functions in my template, but okay |
# |
Mar 6th 2018, 15:56 |
jeremyharris |
the only time it wouldn’t work is if you accessed the prop directly from the entity, like $this->_properties[‘name’] |
# |
Mar 6th 2018, 15:56 |
neon1024 |
Which makes the throwing of a fatal, to me at least, feel like the Entity is enforcing it’s data integrity |
# |
Mar 6th 2018, 15:56 |
dereuromark |
their whole purpose is DTO |
# |
Mar 6th 2018, 15:55 |
dereuromark |
highstrike: reading attributes is one of the main tasks of entities |
# |
Mar 6th 2018, 15:55 |
neon1024 |
Urgh :face_with_open_mouth_vomiting: |
# |
Mar 6th 2018, 15:55 |
jeremyharris |
it works without using get(), via magic methods |
# |
Mar 6th 2018, 15:55 |
neon1024 |
So my entity mutators work |
# |
Mar 6th 2018, 15:54 |
flavius |
why do you use entity->get() in templates? :P |
# |
Mar 6th 2018, 15:54 |
dereuromark |
for obvious reasons, better IDE support |
# |
Mar 6th 2018, 15:54 |
neon1024 |
Perhaps I’ll add a trait to my entities |
# |
Mar 6th 2018, 15:54 |
dereuromark |
it does? ok, I always use properties so far |
# |
Mar 6th 2018, 15:54 |
dereuromark |
oh |
# |
Mar 6th 2018, 15:54 |
neon1024 |
Entity get, not ORM get :slightly_smiling_face: |
# |
Mar 6th 2018, 15:53 |
dereuromark |
you can use find + redirect instead |
# |
Mar 6th 2018, 15:53 |
neon1024 |
Perhaps I need to wrap it my own helper |
# |
Mar 6th 2018, 15:53 |
Es0teric |
flavius its not in error.log... its failing silently even though i have all debug on |
# |
Mar 6th 2018, 15:53 |
neon1024 |
The objective should instead be to try and render something |
# |
Mar 6th 2018, 15:53 |
neon1024 |
Especially as it’s used so extensively in the templates, throwing a fatal bins my entire page |
# |
Mar 6th 2018, 15:52 |
neon1024 |
`->get()` throwing a fatal is a very frustrating behaviour for me |
# |
Mar 6th 2018, 15:51 |
flavius |
well something happens, and you can find the issue in logs/error.log |
# |
Mar 6th 2018, 15:51 |
Es0teric |
the problem is that the method is not accepting a multidimensional array as a return |
# |
Mar 6th 2018, 15:50 |
Es0teric |
i did not overwrite anything |
# |
Mar 6th 2018, 15:50 |
flavius |
es0teric then there's something else that you overwrote and broke your app? because after debug die it returns what you want, so what happens AFTER that breaks it, a cool way to debug your application is with xdebug and break points |
# |
Mar 6th 2018, 15:50 |
dereuromark |
similar to counter cache or slug behaviors |
# |
Mar 6th 2018, 15:49 |
dereuromark |
true, it can be a behavior driven read only cache field so to speak |
# |
Mar 6th 2018, 15:48 |
flavius |
you could make a new table field called full_name and save in it the contents of first_name and last_name to avoid this all together :slightly_smiling_face: |
# |
Mar 6th 2018, 15:48 |
Es0teric |
flavius i fixed that and still |
# |
Mar 6th 2018, 15:45 |
popperz0r |
will try |