Announcement

Collapse
No announcement yet.

Typed property $searchParamsFetcher must not be accessed before initialization

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

  • 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?

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

    Comment


    • #3
      perfect! fixed!
      thanks again!

      Comment

      Working...
      X