Hello I have the following code:
I'm seeing an error message in the beforeSave call:
E_NOTICE: Undefined index: serviceFactory {"code":8,"message":"Undefined index: serviceFactory","file":"/var/espo/espocrm/application/Espo/Core/Hooks/Base.php","line":77,"context":{"name":"serviceFact ory"}} []
I've rebuilt, checked for typos etc. Why wouldn't the addDependency call be working for me?
PHP Code:
<?php
namespace Espo\Modules\MYMODULE\Hooks\Common;
use Espo\ORM\Entity;
class MYCLASS extends \Espo\Core\Hooks\Base
{
protected function init()
{
parent::init();
$this->addDependency('serviceFactory');
}
protected function getServiceFactory()
{
return $this->getInjection('serviceFactory');
}
public function beforeSave(Entity $entity, $initialSync = FALSE)
{
$service = $this->getServiceFactory()->create('MyServiceName');
^^^
}
}
E_NOTICE: Undefined index: serviceFactory {"code":8,"message":"Undefined index: serviceFactory","file":"/var/espo/espocrm/application/Espo/Core/Hooks/Base.php","line":77,"context":{"name":"serviceFact ory"}} []
I've rebuilt, checked for typos etc. Why wouldn't the addDependency call be working for me?
Comment