# |
May 17th, 10:02 |
neon1024 |
@mehov What is the use-case you’re trying to solve? |
# |
May 17th, 09:49 |
dereuromark |
Most hydrate the entity beforehand, it is just a setter here usually, and then do a basic save. |
# |
May 17th, 09:48 |
dereuromark |
passing the entity is fine, that way you encapsulate the save without extra db queries. |
# |
May 17th, 09:25 |
mehov |
So `$article->setAuthor()` should go to the ArticlesTable and become `$this->Articles->setAuthor($article_id)` where it'd retrieve the entity by it's ID, update the property and save the entity?` |
# |
May 17th, 09:11 |
neon1024 |
Have a look at the Repository pattern |
# |
May 17th, 09:11 |
neon1024 |
Even then, the actual Database parts are given to the Table class |
# |
May 17th, 09:11 |
neon1024 |
So the table class is passed an entity to persist |
# |
May 17th, 09:11 |
neon1024 |
The Table class knows how to persist and retrieve objects |
# |
May 17th, 09:11 |
neon1024 |
Nor should it |
# |
May 17th, 09:10 |
neon1024 |
An entity is just a plain object, it doesn’t know about a datastore |
# |
May 17th, 09:10 |
neon1024 |
I’d agree with the author, it does invert the logic |
# |
May 17th, 09:04 |
mehov |
The question originates from me trying to figure out how do I save a `DATETIME` field on an entity to MySQL `NOW()` and googling the above post up |
# |
May 17th, 09:03 |
slackebot |
provide access to a collection of objects, entities represent individual rows or domain objects in your application. Entities contain methods to manipulate and access the data they contain (https://book.cakephp.org/3.0/en/orm/entities.html) |
# |
May 17th, 09:03 |
slackebot |
read that because I naturally thought the code related to acting on an entity would go to an entity, and code related to retrieving entities goes to a table. E.g. $article->setAuthor() sets and saves $this->author and there's no point in cluttering the Articles table code with it. Makes sense to me, but the guy above says that inverts the architecture. Is that right? Because the documentation isn't as strict. > While Table Objects represent and |
# |
May 17th, 09:03 |
mehov |
Hey everyone, I have an app-architecture question. > First, I would not do any business logic operations inside an entity. Especially not placing the code inside the entity. <..> An entity is thought to be a data object, nothing more. So doing save operations inside the entity inverts the architecture. (https://stackoverflow.com/questions/35697514/cakephp-3-0-using-mysql-functions-in-entities/35697791#35697791) I was somewhat surprised to |
# |
May 17th, 09:00 |
slackebot |
<neon1024> |
# |
May 17th, 08:51 |
nils |
Is dereuromark in here? |
# |
May 17th, 08:28 |
neon1024 |
You’d search by hash |
# |
May 17th, 08:24 |
welo.lamacchia |
so, when i'll search by foreign_key i have to decode the hashId ? |
# |
May 17th, 08:21 |
admad |
your relations would break |
# |
May 17th, 08:21 |
admad |
you can't obfuscate foreign keys, |
# |
May 17th, 08:21 |
welo.lamacchia |
:S |
# |
May 17th, 08:21 |
welo.lamacchia |
and not work well |
# |
May 17th, 08:21 |
welo.lamacchia |
but only obfuscate primary key |
# |
May 17th, 08:21 |
welo.lamacchia |
i tried this one: https://github.com/dereuromark/cakephp-hashid |
# |
May 17th, 08:20 |
admad |
@welo.lamacchia https://github.com/usemuffin/obfuscate |
# |
May 17th, 08:19 |
welo.lamacchia |
hello everyone! Is there a way to obfuscate all primary keys and foreign keys for my tables ? |
# |
May 17th, 06:36 |
admad |
np, thanks |
# |
May 17th, 06:33 |
hmic |
thanks for clarifying. |
# |
May 17th, 06:32 |
hmic |
there you go: https://github.com/cakephp/cakephp/issues/13249 |
# |
May 17th, 06:22 |
admad |
In the meantime you can do the fix in your app and use your own ActionDispatcher. Override Application::getDispatcher() to return your own dispatcher instance |
# |
May 17th, 06:21 |
admad |
Please open an issue |
# |
May 17th, 06:21 |
admad |
Fix is easy, ActionDispatcher::_invoke() should check and set return value of invokeAction() call. |
# |
May 17th, 06:20 |
hmic |
either i need that be accurate in the afterFilter callback, or I need access to the resposne that has been returned from the action in the event data somehow |
# |
May 17th, 06:20 |
hmic |
yep |
# |
May 17th, 06:18 |
admad |
that's the problem you are facing right? |
# |
May 17th, 06:17 |
admad |
hmm.. yeah Controller::$response never get's updated if an action explicitly return response. It's updated only when render() is called |
# |
May 17th, 06:13 |
hmic |
it's jsut weird that it has no access to the response object that has been returned bz an action, but is able to return a response that will be send... |
# |
May 17th, 06:12 |
hmic |
admad: each controller, same per action. thats why i wanted to use afterFilter |
# |
May 17th, 05:35 |
admad |
are the headers different for each action/controller? |
# |
May 17th, 05:18 |
hmic |
i need to add for post/put/delete too |