Typed property $searchParamsFetcher must not be accessed before initialization

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Serge
    Junior Member
    • Oct 2023
    • 5

    Typed property $searchParamsFetcher must not be accessed before initialization

    I'm struggling with some weird error once I go to my custom entity via de browser: ERROR: Slim Application Error Type: Error Code: 0 Message: Typed property Espo\Core\Controllers\RecordBase::$searchParamsFet cher must not be accessed before initialization.

    I have created a custom controller via the entity manager and added the following code:
    Code:
    <?php
    namespace Espo\Custom\Controllers;
    use Espo\Custom\Services\EmptyService;
    class CallbackEntity extends \Espo\Core\Templates\Controllers\Base
    {
        public function __construct(private EmptyService $emptyService)
        { }
    }​
    The code of my service is:
    Code:
    <?php
    namespace Espo\Custom\Services;
    class EmptyService
    {
        public function getEmptyValue(): string
        {
            return "empty value";
        }
    }​
    If i comment the __contruct it's all working. What is going wrong here?
  • yuri
    Member
    • Mar 2014
    • 8455

    #2
    This is more PHP language question. You don't call parent constructor. I would not recommend extend the constructor.

    I recommend using an Action class instead: https://docs.espocrm.com/development/api-action/#action
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • wtconseil
      Active Community Member
      • Apr 2015
      • 335

      #3
      perfect! fixed!
      thanks again!

      Comment

      Working...