# |
Feb 7th 2018, 16:46 |
diego182 |
Hello, when i have a update... when i patch entity i have to set the ID(PK) of the entity. Now lets assume that i have an array with data to update that entity This array has an combination of values on where i can decide weather its a new entity or update Is there an way to patch an entity without this ID? |
# |
Feb 7th 2018, 16:43 |
neon1024 |
If you want to check, have a look at the Session tab in DebugKit |
# |
Feb 7th 2018, 16:43 |
ank068 |
Okay cool thanks :slightly_smiling_face: |
# |
Feb 7th 2018, 16:43 |
neon1024 |
Yup |
# |
Feb 7th 2018, 16:43 |
ank068 |
So even write and read are access through that? |
# |
Feb 7th 2018, 16:41 |
diego182 |
sessions are on the request and response objects |
# |
Feb 7th 2018, 16:41 |
neon1024 |
@ank068 No you don’t, as the Session is part of the request. `$this->request->getSession()` |
# |
Feb 7th 2018, 16:41 |
ank068 |
Do i need to add a "use" statement in controllers to work with sessions? |
# |
Feb 7th 2018, 16:40 |
neon1024 |
Man, I still don’t like that `->get()` throws a fatal when stuff isn’t there. |
# |
Feb 7th 2018, 16:25 |
slackebot |
!xy |
# |
Feb 7th 2018, 16:25 |
slackebot |
Command sent from Slack by neon1024: |
# |
Feb 7th 2018, 16:24 |
neon1024 |
It seems an unnecessary thing to want to do |
# |
Feb 7th 2018, 16:24 |
neon1024 |
Or should I say why do you need Capitalised entity properties? |
# |
Feb 7th 2018, 16:24 |
neon1024 |
What are you trying to achieve? |
# |
Feb 7th 2018, 15:54 |
devito |
however virtual properties do the inverse of what I am looking for it seems. |
# |
Feb 7th 2018, 15:52 |
devito |
atm im trying to achieve this by setting virtual properties |
# |
Feb 7th 2018, 15:51 |
devito |
Right, Im looking to Inflect::classify after I retrieve my records |
# |
Feb 7th 2018, 15:49 |
neon1024 |
@devito This is the job of the Inflector class, see https://inflector.cakephp.org/ |
# |
Feb 7th 2018, 15:46 |
devito |
Hello All. is there a way to Inflect entity property names as class names after find? I looked into map / reduce but I dont think it is nessessarly suited for this situation example I want to make $entity->name become $entity->Name I am setting virtual names but was wondering if theres a better way. |
# |
Feb 7th 2018, 15:35 |
popperz0r |
right? |
# |
Feb 7th 2018, 15:35 |
popperz0r |
```use Cake\Event\EventManager; EventManager::instance()->on( new App\Event\UserNotification() ); ``` |
# |
Feb 7th 2018, 15:35 |
popperz0r |
bootstrap.php |
# |
Feb 7th 2018, 15:35 |
popperz0r |
```namespace App\Event; use Cake\Event\EventListenerInterface; use Cake\ORM\TableRegistry; class UserNotification implements EventListenerInterface``` |
# |
Feb 7th 2018, 15:35 |
popperz0r |
`src/Event/UserNotification.php` |
# |
Feb 7th 2018, 15:34 |
popperz0r |
I think ive done it, maybe im missing something |
# |
Feb 7th 2018, 15:31 |
neon1024 |
@popperz0r http://php.net/manual/en/language.namespaces.importing.php |
# |
Feb 7th 2018, 15:27 |
popperz0r |
Im already using a copy of that code inside a Plugin and is working :P |
# |
Feb 7th 2018, 15:27 |
popperz0r |
What do you mean? |
# |
Feb 7th 2018, 15:24 |
dereuromark |
or use proper use statements |
# |
Feb 7th 2018, 15:24 |
dereuromark |
leading \ ? |
# |
Feb 7th 2018, 15:24 |
popperz0r |
anyone? :S |
# |
Feb 7th 2018, 15:22 |
popperz0r |
```Class 'App\Event\UserNotification' not found``` |
# |
Feb 7th 2018, 15:22 |
popperz0r |
that isnt working |
# |
Feb 7th 2018, 15:21 |
popperz0r |
```EventManager::instance()->on( new App\Event\UserNotification() );``` |
# |
Feb 7th 2018, 15:21 |
popperz0r |
into |
# |
Feb 7th 2018, 15:21 |
popperz0r |
Hi guys! How can i load a file in src/Event/Folder ? |
# |
Feb 7th 2018, 15:18 |
neon1024 |
When I next think it’s okay to make a ‘manage’ method which does both add and edit. Someone stop me. |
# |
Feb 7th 2018, 14:37 |
admad |
@o0h i'll talk with the team and get it sorted out |
# |
Feb 7th 2018, 14:34 |
admad |
yes that annotation is wrong, `$this->_connection` would be a PDO instance, but if you add `@property \PDO|null $_connection` annotation to Driver class then phpstan complains that lastInsertId() is called with 2 params when PDO::lastInsertId() takes only one :slightly_smiling_face: |
# |
Feb 7th 2018, 14:31 |
o0h |
@admad thanks! i wonder why it is in there, and feel it’s better to remove the annotation from ConnectionInterface.. ;( Can I send patch to fix it? |
# |
Feb 7th 2018, 14:29 |
eax |
admad: I've tried changing what you pointed out, to ['json'], false, and even removing it, sadly to no avail :/ |