Announcement

Collapse
No announcement yet.

Can't return Metadata for field

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't return Metadata for field

    Hey,

    PHP Code:
    public static function getFieldDef($fieldName)
        {
            
    $fileManager = new Manager();
            
    $config = new Config($fileManager);
            
    // $fieldName passing this value -> investmentPortfolios
            
    $metadata = new Metadata();
            
    file_put_contents('/var/www/espocrm/data/logs/x.log'print_r($metadata->get('entityDefs.Account.fields'), true));

        } 
    I just adding above code in this location espocrm\custom\Espo\Custom\Hooks\Account but each time I run above code the below error message appears

    HTML Code:
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP Fatal error:  Call to a member function getFileList() on null in /var/www/espocrm/application/Espo/Core/Utils/File/Unifier.php on line 111, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP Stack trace:, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   1. {main}() /var/www/espocrm/api/v1/index.php:0, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   2. Espo\\Core\\Application->run() /var/www/espocrm/api/v1/index.php:33, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   3. Espo\\Core\\Utils\\Api\\Slim->run() /var/www/espocrm/application/Espo/Core/Application.php:88, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   4. Espo\\Core\\Utils\\Api\\Auth->call() /var/www/espocrm/application/Espo/Core/Utils/Api/Slim.php:125, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   5. Slim\\Middleware\\MethodOverride->call() /var/www/espocrm/application/Espo/Core/Utils/Api/Auth.php:112, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   6. Slim\\Middleware\\Flash->call() /var/www/espocrm/vendor/slim/slim/Slim/Middleware/MethodOverride.php:92, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   7. Slim\\Slim->call() /var/www/espocrm/vendor/slim/slim/Slim/Middleware/Flash.php:85, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   8. Slim\\Slim->applyHook() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1315, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP   9. call_user_func:{/var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175}() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  10. Espo\\Core\\Application->Espo\\Core\\{closure}() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  11. Espo\\Core\\ControllerManager->process() /var/www/espocrm/application/Espo/Core/Application.php:226, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  12. Espo\\Core\\Controllers\\Record->actionPatch() /var/www/espocrm/application/Espo/Core/ControllerManager.php:116, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  13. Espo\\Core\\Controllers\\Record->actionUpdate() /var/www/espocrm/application/Espo/Core/Controllers/Record.php:81, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  14. Espo\\Services\\Record->updateEntity() /var/www/espocrm/application/Espo/Core/Controllers/Record.php:115, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  15. Espo\\Services\\Record->storeEntity() /var/www/espocrm/application/Espo/Services/Record.php:654, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  16. Espo\\Core\\ORM\\Repositories\\RDB->save() /var/www/espocrm/application/Espo/Services/Record.php:373, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  17. Espo\\ORM\\Repositories\\RDB->save() /var/www/espocrm/application/Espo/Core/ORM/Repositories/RDB.php:319, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  18. Espo\\Core\\ORM\\Repositories\\RDB->afterSave() /var/www/espocrm/application/Espo/ORM/Repositories/RDB.php:147, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  19. Espo\\Core\\HookManager->process() /var/www/espocrm/application/Espo/Core/ORM/Repositories/RDB.php:275, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  20. Espo\\Custom\\Hooks\\AccountOpening\\AccountOpening->afterSave() /var/www/espocrm/application/Espo/Core/HookManager.php:122, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  21. Espo\\Custom\\Hooks\\AccountOpening\\MissingHandler::verifyInvestmentPortfolios() /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/AccountOpening.php:27, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  22. Espo\\Custom\\Hooks\\AccountOpening\\MissingHandler::getFieldDef() /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/MissingHandler.php:336, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  23. Espo\\Core\\Utils\\Metadata->get() /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/MissingHandler.php:30, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  24. Espo\\Core\\Utils\\Metadata->getData() /var/www/espocrm/application/Espo/Core/Utils/Metadata.php:183, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  25. Espo\\Core\\Utils\\Metadata->init() /var/www/espocrm/application/Espo/Core/Utils/Metadata.php:167, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  26. Espo\\Core\\Utils\\File\\Unifier->unify() /var/www/espocrm/application/Espo/Core/Utils/Metadata.php:147, referer: http://10.20.50.206/
    [Mon Nov 20 14:32:58 2017] [error] [client 10.20.22.193] PHP  27. Espo\\Core\\Utils\\File\\Unifier->unifySingle() /var/www/espocrm/application/Espo/Core/Utils/File/Unifier.php:75, referer: http://10.20.50.206/
    thanks in advanced

  • #2
    Hello
    in application/Espo/Hooks/Common/Stream.php you have an example with Metadata
    why do you create objects, if they are available in this class?

    Comment


    • #3
      I was followed this documentation https://www.espocrm.com/documentatio...ment/metadata/
      and I was changed to be like below but still not working and I'm got the same error as I mentioned before

      PHP Code:
      file_put_contents('/var/www/espocrm/data/logs/x.log'
                                  
      print_r($this->getMetadata()->get('entityDefs.AccountOpening.fields.investmentPortfolios'), true)); 

      Comment


      • #4
        here's the error message

        HTML Code:
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP Fatal error:  Call to a member function get() on null in /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/MissingHandler.php on line 30, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP Stack trace:, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   1. {main}() /var/www/espocrm/api/v1/index.php:0, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   2. Espo\\Core\\Application->run() /var/www/espocrm/api/v1/index.php:33, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   3. Espo\\Core\\Utils\\Api\\Slim->run() /var/www/espocrm/application/Espo/Core/Application.php:88, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   4. Espo\\Core\\Utils\\Api\\Auth->call() /var/www/espocrm/application/Espo/Core/Utils/Api/Slim.php:125, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   5. Slim\\Middleware\\MethodOverride->call() /var/www/espocrm/application/Espo/Core/Utils/Api/Auth.php:112, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   6. Slim\\Middleware\\Flash->call() /var/www/espocrm/vendor/slim/slim/Slim/Middleware/MethodOverride.php:92, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   7. Slim\\Slim->call() /var/www/espocrm/vendor/slim/slim/Slim/Middleware/Flash.php:85, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   8. Slim\\Slim->applyHook() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1315, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP   9. call_user_func:{/var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175}() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  10. Espo\\Core\\Application->Espo\\Core\\{closure}() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  11. Espo\\Core\\ControllerManager->process() /var/www/espocrm/application/Espo/Core/Application.php:226, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  12. Espo\\Core\\Controllers\\Record->actionPatch() /var/www/espocrm/application/Espo/Core/ControllerManager.php:116, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  13. Espo\\Core\\Controllers\\Record->actionUpdate() /var/www/espocrm/application/Espo/Core/Controllers/Record.php:81, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  14. Espo\\Services\\Record->updateEntity() /var/www/espocrm/application/Espo/Core/Controllers/Record.php:115, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  15. Espo\\Services\\Record->storeEntity() /var/www/espocrm/application/Espo/Services/Record.php:654, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  16. Espo\\Core\\ORM\\Repositories\\RDB->save() /var/www/espocrm/application/Espo/Services/Record.php:373, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  17. Espo\\ORM\\Repositories\\RDB->save() /var/www/espocrm/application/Espo/Core/ORM/Repositories/RDB.php:319, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  18. Espo\\Core\\ORM\\Repositories\\RDB->afterSave() /var/www/espocrm/application/Espo/ORM/Repositories/RDB.php:147, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  19. Espo\\Core\\HookManager->process() /var/www/espocrm/application/Espo/Core/ORM/Repositories/RDB.php:275, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  20. Espo\\Custom\\Hooks\\AccountOpening\\AccountOpening->afterSave() /var/www/espocrm/application/Espo/Core/HookManager.php:122, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  21. Espo\\Custom\\Hooks\\AccountOpening\\MissingHandler->verifyInvestmentPortfolios() /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/AccountOpening.php:27, referer: http://10.20.50.206/
        [Mon Nov 20 16:26:12 2017] [error] [client 10.20.22.193] PHP  22. Espo\\Custom\\Hooks\\AccountOpening\\MissingHandler->getFieldDef() /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/MissingHandler.php:338, referer: http://10.20.50.206/
        
        
        Last edited by wmoghes; 11-20-2017, 02:29 PM.

        Comment


        • #5
          Does your class extend base?

          Comment


          • #6
            yeah I already use extend like below
            PHP Code:
            namespace Espo\Custom\Hooks\AccountOpening;

            use 
            Espo\ORM\Entity;
            use 
            Espo\Core\Utils\Util;
            use 
            Espo\Core\Utils\Metadata;
            use 
            Espo\Core\Utils\Config;
            use 
            Espo\Core\Utils\File\Manager;

            class 
            MissingHandler extends \Espo\Core\Hooks\Base 

            Comment


            • #7
              I tried to change the code to be like this and got the same error -> "PHP Fatal error: Call to a member function get() on null"


              PHP Code:
              public function getFieldDef($fieldName)
                  {
                      
              $fileManager = new Manager();
                      
              $config = new Config($fileManager);
                      
              // $metadata = new Metadata($config, $fileManager);// investmentPortfolios
                      
              file_put_contents('/var/www/espocrm/data/logs/x.log'
                                          
              print_r($this->getMetadata()->get('entityDefs.AccountOpening.fields'), true));
                      
              //$metadata = new Metadata();
                      //file_put_contents('/var/www/espocrm/data/logs/x.log', print_r($metadata->get('entityDefs.Account.fields'), true));
                      //$field = $metadata->get('entityDefs.AccountOpening.fields.' . $fieldName);
                      //$field = $metadata->get('entityDefs.AccountOpening.fields.investmentPortfolios.type');
                      //return $field['options'];

                  

              I'm sorry for the inconvenience but I hope if you can help me in this issue because i tried my best

              HTML Code:
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP Fatal error:  Call to a member function get() on null in /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/MissingHandler.php on line 30, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP Stack trace:, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   1. {main}() /var/www/espocrm/api/v1/index.php:0, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   2. Espo\\Core\\Application->run() /var/www/espocrm/api/v1/index.php:33, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   3. Espo\\Core\\Utils\\Api\\Slim->run() /var/www/espocrm/application/Espo/Core/Application.php:88, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   4. Espo\\Core\\Utils\\Api\\Auth->call() /var/www/espocrm/application/Espo/Core/Utils/Api/Slim.php:125, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   5. Slim\\Middleware\\MethodOverride->call() /var/www/espocrm/application/Espo/Core/Utils/Api/Auth.php:112, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   6. Slim\\Middleware\\Flash->call() /var/www/espocrm/vendor/slim/slim/Slim/Middleware/MethodOverride.php:92, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   7. Slim\\Slim->call() /var/www/espocrm/vendor/slim/slim/Slim/Middleware/Flash.php:85, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   8. Slim\\Slim->applyHook() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1315, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP   9. call_user_func:{/var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175}() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  10. Espo\\Core\\Application->Espo\\Core\\{closure}() /var/www/espocrm/vendor/slim/slim/Slim/Slim.php:1175, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  11. Espo\\Core\\ControllerManager->process() /var/www/espocrm/application/Espo/Core/Application.php:226, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  12. Espo\\Core\\Controllers\\Record->actionPatch() /var/www/espocrm/application/Espo/Core/ControllerManager.php:116, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  13. Espo\\Core\\Controllers\\Record->actionUpdate() /var/www/espocrm/application/Espo/Core/Controllers/Record.php:81, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  14. Espo\\Services\\Record->updateEntity() /var/www/espocrm/application/Espo/Core/Controllers/Record.php:115, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  15. Espo\\Services\\Record->storeEntity() /var/www/espocrm/application/Espo/Services/Record.php:654, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  16. Espo\\Core\\ORM\\Repositories\\RDB->save() /var/www/espocrm/application/Espo/Services/Record.php:373, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  17. Espo\\ORM\\Repositories\\RDB->save() /var/www/espocrm/application/Espo/Core/ORM/Repositories/RDB.php:319, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  18. Espo\\Core\\ORM\\Repositories\\RDB->afterSave() /var/www/espocrm/application/Espo/ORM/Repositories/RDB.php:147, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  19. Espo\\Core\\HookManager->process() /var/www/espocrm/application/Espo/Core/ORM/Repositories/RDB.php:275, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  20. Espo\\Custom\\Hooks\\AccountOpening\\AccountOpening->afterSave() /var/www/espocrm/application/Espo/Core/HookManager.php:122, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  21. Espo\\Custom\\Hooks\\AccountOpening\\MissingHandler->verifyInvestmentPortfolios() /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/AccountOpening.php:27, referer: http://10.20.50.206/
              [Mon Nov 20 16:44:07 2017] [error] [client 10.20.22.193] PHP  22. Espo\\Custom\\Hooks\\AccountOpening\\MissingHandler->getFieldDef() /var/www/espocrm/custom/Espo/Custom/Hooks/AccountOpening/MissingHandler.php:338, referer: http://10.20.50.206/

              Comment


              • #8
                Any news on this case, DevMostafa , tanya

                Comment

                Working...
                X