Extend entity class from a (vendor) plugin (Acl)


#1

Hi

I would like to extend the “Aco Entity Class” of the Acl plugin installed via composer with a custom method.

Ive tried to create the App\Model\Entity\Aco.php with the desired method. But the class won’t be used at all. Is this even possible? How? :wink:

Thanks,
Frank


#2

Ive tried it so:

namespace App\Model\Entity;

use Acl\Model\Entity\Aco as ParentAco;

class Aco extends ParentAco
{
protected $_virtual = [‘text’];

/**
* Create virtual field “text”
*
* @return string text
*/
protected function _getText()
{
if (empty($this->_properties[‘text’])) {
return $this->_properties[‘alias’];
}
return $this->_properties[‘text’];
}
}


#3

Did you extend the table class too? You can then call loadModel on that table class, which should use your extended entity class in turn…?


#4

Yes, I have extended the TableClass too, although there is no need for any new functionality.

In the TableClass I had access when unloading with “TabelRegistry::clear” and then loading the the new EntityClass with TableRegsitry::get.

But this feels a bit odd and evil :wink:

Any chance to get this to work only adding a EntiyClass?