# |
Feb 7th 2018, 17:38 |
diego182 |
areyou trying to echo this? @ank068 |
# |
Feb 7th 2018, 17:36 |
ank068 |
Would it be because of one the fields? |
# |
Feb 7th 2018, 17:35 |
ank068 |
Any reason why i am getting this error "Object of class App\Model\Table\AdminsTable could not be converted to string" on a simple "$this->$admin_table->find('all');"? |
# |
Feb 7th 2018, 17:04 |
diego182 |
the problem is that this data comer from a foreign source, so i cannot guarantee that i have an unique key |
# |
Feb 7th 2018, 17:03 |
neon1024 |
Take a quick look in the EntityTrait to ensure there isn’t a neater way to enumerate it’s properties |
# |
Feb 7th 2018, 17:02 |
diego182 |
humm gonna try something like this |
# |
Feb 7th 2018, 16:58 |
neon1024 |
Or something similar. At least that would be my first attempt approach |
# |
Feb 7th 2018, 16:58 |
neon1024 |
Then you could just use `new MyEntity(array_merge($oldEntity->toArray(), $arrayOfNewThings))` |
# |
Feb 7th 2018, 16:58 |
neon1024 |
If you want to kind of patch it, hmm, I’d think about trying `array_merge`, but you might need to implement a `toArray()` method in the entity, unless it implements the `ArrayAccess` interface |
# |
Feb 7th 2018, 16:57 |
neon1024 |
So you could just assign the new data to it directly, without any issue. `$entity->set('diego182', true);` |
# |
Feb 7th 2018, 16:56 |
neon1024 |
Well an entity is a standard PHP class |
# |
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 \ ? |