Error on Version 4.8.4

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DevMostafa
    Member
    • Mar 2017
    • 36

    #16
    Yes, I will upload you the two hooks I made.
    Attached Files

    Comment

    • DevMostafa
      Member
      • Mar 2017
      • 36

      #17
      These are the custom hooks itself
      Attached Files

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #18
        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

        • DevMostafa
          Member
          • Mar 2017
          • 36

          #19
          Yes, It's working well.
          It logs into the file 'Welcome Waleed'
          Last edited by DevMostafa; 12-18-2017, 09:17 AM.

          Comment

          • DevMostafa
            Member
            • Mar 2017
            • 36

            #20
            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

          • DevMostafa
            Member
            • Mar 2017
            • 36

            #21
            tanya Thanks Tanya for your great effort and help, I got it now.
            I think it's working now.

            Comment

            Working...