# |
Feb 6th 2018, 13:09 |
neon1024 |
I am not seeing any output from my entity mutators. I am working in a plugin. I have set in the plugin Table class, `setEntity()` to the plugin entity, and still the Paginator is returning `Cake\ORM\Entity` instead of my entity class. What have I missed? |
# |
Feb 6th 2018, 12:35 |
neon1024 |
Thanks @admad |
# |
Feb 6th 2018, 12:34 |
neon1024 |
But any docs contribution is a good one :thumbsup: |
# |
Feb 6th 2018, 12:34 |
neon1024 |
Well I was going to be a little more verbose and talk about the marshaller |
# |
Feb 6th 2018, 12:30 |
admad |
@neon1024 https://github.com/cakephp/docs/pull/5602 |
# |
Feb 6th 2018, 12:25 |
neon1024 |
I’m sure there will be some discussion on the PR :slightly_smiling_face: |
# |
Feb 6th 2018, 12:24 |
neon1024 |
Which is why the docs confused me by putting the direct method first |
# |
Feb 6th 2018, 12:24 |
neon1024 |
I would think in most cases you’d want to use the Table class |
# |
Feb 6th 2018, 12:24 |
neon1024 |
The only difference I can see is the one I mentioned above |
# |
Feb 6th 2018, 12:23 |
neon1024 |
They both return an entity |
# |
Feb 6th 2018, 12:22 |
hmic |
Entity != TableEntity |
# |
Feb 6th 2018, 12:22 |
neon1024 |
What do you mean? The calling class or the result? |
# |
Feb 6th 2018, 12:19 |
hmic |
neon1024: what class is new Entity vs. $table->newEntity()? |
# |
Feb 6th 2018, 12:17 |
neon1024 |
Think I’ll suggest an amend to the docs when I’m done :slightly_smiling_face: |
# |
Feb 6th 2018, 12:16 |
neon1024 |
That feels like something which should be told to users here, https://book.cakephp.org/3.0/en/orm/entities.html#creating-entities |
# |
Feb 6th 2018, 12:15 |
neon1024 |
What is the difference between `$entity = new Entity(['foo' => 'bar']);` and `$entity = $this->Examples->newEntity(['foo' => 'bar']);` as in, why is using the repository different? Is it just that the Table class will run the marshaller, whereas direct instantiation will only assign values? |
# |
Feb 6th 2018, 12:13 |
neon1024 |
`find()->where(['tags LIKE' => $tags])` |
# |
Feb 6th 2018, 12:02 |
h.mavisakalian |
find(‘all’, [ ‘conditions’ => [ ‘user_id’ => $user[‘id’], ‘tags’ => ‘LIKE $string’ ] ]) |
# |
Feb 6th 2018, 12:02 |
h.mavisakalian |
something like |
# |
Feb 6th 2018, 12:01 |
h.mavisakalian |
How can I add a exists condition when fetching data from table ? example.. I need to see if the string contains data from another string… |
# |
Feb 6th 2018, 10:22 |
neon1024 |
With a find() I mean, obviously not a first() as that’s taking a single item from the collection |
# |
Feb 6th 2018, 10:22 |
neon1024 |
As a query returns a ResultSet which implement ResultSet interface, it is a sensible default to assume the collection contains entities? |
# |
Feb 6th 2018, 09:42 |
neon1024 |
Ahh a fork |
# |
Feb 6th 2018, 09:42 |
neon1024 |
https://github.com/dereuromark/CakePHP-DatabaseLog |
# |
Feb 6th 2018, 09:42 |
neon1024 |
I was going to say I bet @dereuromark has done it already, and well.. whaddya know! |
# |
Feb 6th 2018, 09:41 |
neon1024 |
Hahaha! |
# |
Feb 6th 2018, 09:39 |
slackebot |
!awesome |
# |
Feb 6th 2018, 09:39 |
slackebot |
Command sent from Slack by neon1024: |
# |
Feb 6th 2018, 09:39 |
neon1024 |
Sounds like a good opportunity to write a plugin |
# |
Feb 6th 2018, 09:32 |
hmic |
but it's only 3 methods you need to implement to make it work, should be a breeze |
# |
Feb 6th 2018, 09:32 |
hmic |
i would have bet my bottom dollar ont hat |
# |
Feb 6th 2018, 09:32 |
hmic |
actually, there seems not to be one in the core :[ |
# |
Feb 6th 2018, 09:31 |
neon1024 |
Thanks for the tip hmic, I’ll look into that :slightly_smiling_face: |
# |
Feb 6th 2018, 09:31 |
neon1024 |
http://woofraise.com/blog1/wp-content/uploads/2012/08/no-way-tell-me-more.jpg |
# |
Feb 6th 2018, 09:30 |
neon1024 |
ORLY? |
# |
Feb 6th 2018, 09:30 |
hmic |
what would your read on the other hand? - yeah a database. there is a database log adapter! |
# |
Feb 6th 2018, 09:30 |
neon1024 |
Think I’ll just add a config value and log directly to the ORM |
# |
Feb 6th 2018, 09:29 |
neon1024 |
I don’t want to use actual logging because i’ll have to read that text file in the admin |
# |
Feb 6th 2018, 09:29 |
hmic |
so you would write a log? |
# |
Feb 6th 2018, 09:29 |
hmic |
if it's just a simple method call, could even be a trait only you use in the apicontroller and shell |
# |
Feb 6th 2018, 09:29 |
neon1024 |
The idea is that the shell runs on a cron and scheduled in the admin, and I’d like to have a log in the admin with nice display of what’s happened and when |