Hi guys,
i need help creating a case hook.
This is what i have done so far:
Created the Hook file in "custom\Espo\Custom\Hooks\Caseobj\CaseName.php " with this content (i used "Caseobj" instead of "Case" to avoid php keyword problem as explained in another topic) :
After Rebuilding the Backend and cleaning the cache i tried to create a new Case but the Hook was not fired as expected.
So i checked the content of hooks.php in "data\cache\application":
And, as you can see, the code is referencing the wrong entity "Caseobj" instead of "Case".
By changing hooks.php from "return array ( 'Caseobj'" to "return array ( 'Case'" the hook start to fire as expected, but every time i rebuild the backend, hooks.php is recreated with the wrong Case entity (caseobj).
So i really don't understand how am i supposed to create a correct Hook for the Case entity.
Thank you very much in advance for the support.
i need help creating a case hook.
This is what i have done so far:
Created the Hook file in "custom\Espo\Custom\Hooks\Caseobj\CaseName.php " with this content (i used "Caseobj" instead of "Case" to avoid php keyword problem as explained in another topic) :
PHP Code:
<?php
namespace Espo\Custom\Hooks\Caseobj;
use Espo\ORM\Entity;
class CaseName extends \Espo\Core\Hooks\Base
{
public function beforeSave(Entity $entity, array $options = [])
{
$GLOBALS['log']->debug('Test');
}
}
?>
After Rebuilding the Backend and cleaning the cache i tried to create a new Case but the Hook was not fired as expected.
So i checked the content of hooks.php in "data\cache\application":
PHP Code:
<?php
return array (
'Caseobj' =>
array (
'afterSave' =>
array (
0 =>
array (
'className' => '\\Espo\\Custom\\Hooks\\Caseobj\\CaseName',
'order' => 9,
),
),
),................
By changing hooks.php from "return array ( 'Caseobj'" to "return array ( 'Case'" the hook start to fire as expected, but every time i rebuild the backend, hooks.php is recreated with the wrong Case entity (caseobj).
So i really don't understand how am i supposed to create a correct Hook for the Case entity.
Thank you very much in advance for the support.
Comment