# |
May 1st 2019, 13:21 |
neon1024 |
No harm in splitting up functionality into plugins though, but it will add some overhead for maintaining things as you’ll have to remember plugin prefixes and such everywhere |
# |
May 1st 2019, 13:20 |
neon1024 |
@maymeow Also worth remembering that without routing configuration plugins will add a plugin prefix to your routes |
# |
May 1st 2019, 13:17 |
noel |
If you’re looking for re-use within a single project then you should be looking at Components and Behaviours |
# |
May 1st 2019, 13:16 |
noel |
@maymeow my understanding that the point of plugins is re-usability across projects. So if you’re only needing this code for a single project, there’s no reason to make it a plugin. |
# |
May 1st 2019, 13:11 |
maymeow |
hmm maybe stupid question but i trying to read some "best practices for cakephp" and where to put business logic and im curious what about Plugins? When to use it and when its dont necessary? For example lets say im creating blog .. its better to create Blog plugin or put NodesController right in src? |
# |
May 1st 2019, 13:03 |
neon1024 |
Threading, I meant |
# |
May 1st 2019, 13:01 |
neon1024 |
If you need more levels, nesting and such you might consider the Tree behaviour though |
# |
May 1st 2019, 13:00 |
neon1024 |
Hope this helps :thumbsup: |
# |
May 1st 2019, 13:00 |
neon1024 |
Which’ll be an array of `ContentEntity` |
# |
May 1st 2019, 12:59 |
neon1024 |
The property will be ’$contentEntity->get(‘children’)` |
# |
May 1st 2019, 12:59 |
neon1024 |
Should probably be ‘Parents’ on looking at it again :man-shrugging: |
# |
May 1st 2019, 12:58 |
neon1024 |
Then you can inverse it with a hasMany too like `$this->Contents->find()->contain(['Children']);` |
# |
May 1st 2019, 12:58 |
slackebot |
<neon1024> |
# |
May 1st 2019, 12:58 |
neon1024 |
So I can do `$this->Contents->find()->contain(['Parent']);` |
# |
May 1st 2019, 12:57 |
neon1024 |
For example, I have this in my `ContentsTable` |
# |
May 1st 2019, 12:57 |
slackebot |
<neon1024> |
# |
May 1st 2019, 12:57 |
neon1024 |
@noel You can create an association which just specifies all the options, and set them to the same table. The main thing to remember is that the Aliased name of the table will be how you refer to it. |
# |
May 1st 2019, 12:46 |
admad |
@rudy1976s @maymeow meanwhile you can peek in the future https://book.cakephp.org/3.next/en/index.html |
# |
May 1st 2019, 12:42 |
admad |
when either @markstory or @savant wakes up :slightly_smiling_face: |
# |
May 1st 2019, 12:38 |
maymeow |
cookbook is availabele on github but when it will be back online ? :slightly_smiling_face: |
# |
May 1st 2019, 12:19 |
noel |
Hi @neon1024 :slightly_smiling_face: are you able to guide me on creating a self-referencing many to many association (and required SQL)? |
# |
May 1st 2019, 11:38 |
rudy1976s |
good morning! the cookbok id apparently down |
# |
May 1st 2019, 10:46 |
neon1024 |
:thumbsup: |
# |
May 1st 2019, 10:46 |
megan |
@neon1024 yup! Have let the team know - Mark did an optimisation thing last night, so could be related. In the meantime you can use https://book.cakephp.org/3.next/en/index.html :slightly_smiling_face: |
# |
May 1st 2019, 10:42 |
fra.bdn |
Hi, the DebugKit stopped working, on the JS console I get a: 404 for http://localhost/debug-kit/toolbar/<a uuid> And the browser just shows a red square on the bottom right of the screen. |
# |
May 1st 2019, 10:37 |
COOurb |
So it kind adoesn't touch 'entity' and all it's stuff |
# |
May 1st 2019, 10:37 |
COOurb |
well, I'm using update() in query builder. Can it be reason why timestamp doesn't work? |
# |
May 1st 2019, 10:35 |
COOurb |
ye |
# |
May 1st 2019, 10:34 |
kiwi_73 |
is http://book.cakephp.org down? |
# |
May 1st 2019, 10:24 |
COOurb |
nope. doesn't work |
# |
May 1st 2019, 10:22 |
neon1024 |
Here is the documentation https://github.com/cakephp/docs/blob/3.0/en/orm/behaviors/timestamp.rst#using-and-configuring-the-behavior |
# |
May 1st 2019, 10:21 |
COOurb |
ok |
# |
May 1st 2019, 10:21 |
COOurb |
dunno |
# |
May 1st 2019, 10:20 |
neon1024 |
Probably easier to update your schema |
# |
May 1st 2019, 10:20 |
neon1024 |
..and using MySQL of course |
# |
May 1st 2019, 10:20 |
neon1024 |
That might be the root of your issue if you’re not escaping |
# |
May 1st 2019, 10:20 |
neon1024 |
Yes, it is. https://dev.mysql.com/doc/refman/5.7/en/keywords.html#keywords-5-7-detailed-D |
# |
May 1st 2019, 10:19 |
neon1024 |
Isn’t ‘date’ a reserved word? |
# |
May 1st 2019, 10:17 |
COOurb |
$this->addBehavior('Timestamp',['events'=>['Model.beforeSave'=>['date'=>'always']]]); |
# |
May 1st 2019, 10:16 |
neon1024 |
As you can see the behaviour foreach’s the config and updates those fields, https://github.com/cakephp/cakephp/blob/c15a2e9c1933fa5a874c33d2bcb6d63efacf8876/src/ORM/Behavior/TimestampBehavior.php#L101 |
# |
May 1st 2019, 10:15 |
neon1024 |
You can see here that the eventName is configured with specific fields, you overwrite these to use timestamp with your own fields |