Yes, I will upload you the two hooks I made.
Error on Version 4.8.4
Collapse
X
-
-
-
after save hook works well.
public function afterSave(Entity $entity, array $options = array())
{
$GLOBALS['log']->error('here we are');
//file_put_contents('/var/www/advanced/data/logs/aoLog.log', 'Welcome Waleed');
$entityManager = $this->getEntityManager();
return;}
Comment
-
Yes, It's working well.
It logs into the file 'Welcome Waleed'Last edited by DevMostafa; 12-18-2017, 09:17 AM.Comment
-
tanya The error now is:
[2018-01-10 12:55:25] Espo.ERROR: E_RECOVERABLE_ERROR: Object of class Espo\Custom\Hooks\AccountOpening\MissingHandler could not be converted to string {"code":4096,"message":"Object of class Espo\\Custom\\Hooks\\AccountOpening\\MissingHandle r could not be converted to string","file":"/var/www/espo/vendor/monolog/monolog/src/Monolog/Logger.php","line":322,"context":{"level":300,"mes sage":"[object] (Espo\\Custom\\Hooks\\AccountOpening\\MissingHandl er: {})","context":[],"levelName":"WARNING","handlerKey":0,"handler" :"[object] (Espo\\Core\\Utils\\Log\\Monolog\\Handler\\Rotatin gFileHandler: {"errorMessage":null})","ts":"2018-01-10 12:55:25"}} []
[2018-01-10 12:55:25] Espo.ERROR: Uncaught Exception Error: "Call to undefined method Espo\Core\Utils\Metadata::getMetadata()" at /var/www/espo/custom/Espo/Custom/Hooks/MissingHandler.php line 32 {"exception":"[object] (Error(code: 0): Call to undefined method Espo\\Core\\Utils\\Metadata::getMetadata() at /var/www/espo/custom/Espo/Custom/Hooks/MissingHandler.php:32)"} []
this is because the following code:
------------------------------------------------------------------------------------------------------
PHP Code:public function getFieldDef($fieldName) { $fileManager = new Manager(); $config = new Config($fileManager); $metadataObj = new Metadata($fileManager, $config); $entityType = $metadataObj->entityType; $metadata = $metadataObj->getMetadata(); if (!$metadata) { return; } //file_put_contents('/home/logs.txt', $this->getMetadata()->get('entityDefs.AccountOpening.fields')); $defs = $metadata->get('entityDefs.AccountOpening.fields.' . $entityType); //$field = $metadata->get('entityDefs.AccountOpening.fields.' . $fieldName); //print_r($field);return $field; return $defs['options']; }
Comment
-
PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.
PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.
I asked you a lot of times: why do you create new objects, but don't used loaded objects
your hook extends \Espo\Core\Hooks\Base, parent class has method for loading config and metadata
....
from application/Espo/Modules/Crm/Services/Opportunity.php
$options = $this->getMetadata()->get('entityDefs.Opportunity.fields.stage.options' );
-
-
Comment