# |
Jul 13th 2021, 10:39 |
caseyw |
Hello all! I’m our software we have a number of plugins our team has made for mainly new themes, etc. im looking to create some constants on the plugin level to share in the ctp files of the plugin who owns it. Where’s the best place to setup general plugin specific constants? Im doing away with a bunch of magic numbers, etc. this is in Cake 3.9. |
# |
Jul 13th 2021, 10:19 |
paolo.bragagni |
probably I'm done |
# |
Jul 13th 2021, 10:16 |
paolo.bragagni |
mmm didnt understand |
# |
Jul 13th 2021, 10:15 |
dereuromark |
just remember all aliases you encountered, as they must be unique. |
# |
Jul 13th 2021, 10:15 |
paolo.bragagni |
I could cycle in associations but I'd like to make one only cicle |
# |
Jul 13th 2021, 10:14 |
paolo.bragagni |
how to know if the relation is BelongsToMany or HasMany in the cycle? |
# |
Jul 13th 2021, 10:14 |
dereuromark |
@erwane on the other side. Why does it need special ones? invalid syntax ignore maybe, but otherwise: as long as the same Type class is reading it again it shouldn't be a big deal |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
and then it cyclea trough {% for alias, details in relations %} |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
there is {% set relations = associations.BelongsToMany|merge(associations.HasMany) %} |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
in view.twig |
# |
Jul 13th 2021, 10:13 |
paolo.bragagni |
cant go ahead in my problem.. :S |
# |
Jul 13th 2021, 10:12 |
dereuromark |
@erwane sounds like it, yeah |
# |
Jul 13th 2021, 09:50 |
charolastra |
sorry, looks like i've forgot to update setPrimaryKey() |
# |
Jul 13th 2021, 09:44 |
charolastra |
on a table with a composite key consiting of 3 fields a newEntity->save() updates an existent entity (where the 3rd key component is a boolean) instead of persisting the new one. not even doing something like $newScreening = $screening. what's going on? |
# |
Jul 13th 2021, 09:29 |
erwane |
Hi. It's a good idea to PR the `Database\Type\JsonType::toDatabase()` to allows options for json_encode like ` ```JSON_UNESCAPED_UNICODE + JSON_INVALID_UTF8_IGNORE + JSON_UNESCAPED_SLASHES``` Maybe via static `JsonType::setJsonEncodeOptions(int value)` |
# |
Jul 12th 2021, 20:24 |
kevin.pfeifer |
oh wow, the cookbook is build via the python library `cakephpsphinx` :cold_sweat: |
# |
Jul 12th 2021, 19:59 |
tyler.adam.lazenby |
are you using cannoical links with your cakephp website? |
# |
Jul 12th 2021, 19:57 |
tyler.adam.lazenby |
the company name is deprecated btw, so don't @ me for that |
# |
Jul 12th 2021, 19:57 |
tyler.adam.lazenby |
```if ($this->request->is(['POST', 'PUT'])) { $data = $this->request->getData(); $data['account_id'] = $current_user->account_id; $data['company_name'] = $current_user->account->name; $data['token'] = Security::randomString();``` ... |
# |
Jul 12th 2021, 19:57 |
tyler.adam.lazenby |
well this way works for now |
# |
Jul 12th 2021, 19:56 |
kevin.pfeifer |
or jsut a Table method if its just for 1 table/entity type |
# |
Jul 12th 2021, 19:56 |
kevin.pfeifer |
you could make a behavior which populates you empty entites with a given set of default data |
# |
Jul 12th 2021, 19:55 |
kevin.pfeifer |
well the default `newEmptyEntity` method just creates a new entity object of whatever is given to it so no default data there |
# |
Jul 12th 2021, 19:55 |
cnizzardini |
there are times where automated jobs or events trigger stuff though :man-shrugging: |
# |
Jul 12th 2021, 19:54 |
cnizzardini |
or doing things |
# |
Jul 12th 2021, 19:54 |
cnizzardini |
its not the worst thing, generally you only want a single source for creating things |
# |
Jul 12th 2021, 19:53 |
kevin.pfeifer |
maybe some other MVC gurus can give you other insights of why this needs to be done this way |
# |
Jul 12th 2021, 19:52 |
cnizzardini |
there is no way to call entity->isNew() or whatever from there to isolate it to new creations |
# |
Jul 12th 2021, 19:52 |
kevin.pfeifer |
:) |
# |
Jul 12th 2021, 19:52 |
kevin.pfeifer |
It would also be nice if the cakephp book would “remember” where I was when switching from 3 to 4 Like https://book.cakephp.org/3/en/orm/table-objects.html and then clicking on the 4.x link at the top right should lead me to https://book.cakephp.org/4/en/orm/table-objects.html |
# |
Jul 12th 2021, 19:52 |
tyler.adam.lazenby |
I just hate it |
# |
Jul 12th 2021, 19:52 |
tyler.adam.lazenby |
Kevin you might be right here |
# |
Jul 12th 2021, 19:51 |
tyler.adam.lazenby |
gosh dang it |
# |
Jul 12th 2021, 19:51 |
tyler.adam.lazenby |
lets see if update changes the value |
# |
Jul 12th 2021, 19:50 |
tyler.adam.lazenby |
hmmm |
# |
Jul 12th 2021, 19:50 |
tyler.adam.lazenby |
except |
# |
Jul 12th 2021, 19:50 |
cnizzardini |
cool, again, id test various scenarios with that |
# |
Jul 12th 2021, 19:50 |
tyler.adam.lazenby |
its used in API calls |
# |
Jul 12th 2021, 19:50 |
tyler.adam.lazenby |
Because this value should never be user created |
# |
Jul 12th 2021, 19:49 |
tyler.adam.lazenby |
before marshall works here |
# |
Jul 12th 2021, 19:49 |
kevin.pfeifer |
behaviors are just re-usable model logic which can be applied to multiple models like components are to controllers |