jeremyharris / cakephp-lazyload

A lazy loader for CakePHP entities.
MIT License
61 stars 10 forks source link

Plugin support if the source is unknown #2

Closed GerardSmit closed 8 years ago

GerardSmit commented 8 years ago

This will get the Table from the plugin if the entity is from a plugin.

For example: new \Cake\ORM\Entity() > table Entities new \Plugin\Model\Entity\Example() > table Plugin.Examples

jeremyharris commented 8 years ago

Thanks for the PR! :)

I'm a little hesitant about this because it bumps the version requirements to 3.2, and assumes entities are stored in Mode/Entity namespace which isn't always the case.

Maybe the documentation should be more clear about this "feature." Is this something you ran into in your plugin tests... or elsewhere?

GerardSmit commented 8 years ago

I've used the part of the code somewhere else; where I needed the tabel name of the model and store it. But since it didn't work with plugins I needed to add that part and wanted to give something back for it. :)

But what you said is true, since in the table you can call entityClass. You could get the prefix of the plugin from the Plugin class, but I don't know if it's efficent and worthfully for this plugin.

jeremyharris commented 8 years ago

I think that in the cases where this is needed, overriding _repository() would be okay to ask of people. I don't know that we should make assumptions from the namespace.