Announcement

Collapse
No announcement yet.

Mapper Factory with Dependency Injection exception

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

  • Mapper Factory with Dependency Injection exception

    Hello!
    I created Mapper Factory which will create my custom Mapper. I've binded Mapper Factory interface with my implementation of Mapper Factory
    This is my Mapper Factory

    PHP Code:
    class MapperFactory implements \Espo\ORM\Mapper\MapperFactory
    {
    public function 
    __construct(
    protected 
    EntityFactory $entityFactory,
    protected 
    QueryExecutor $queryExecutor,
    ) {
    }

    #[
    \Override] public function create(string $name): Mapper
    {
    return match (
    $name) {
    'machine' => new MachineMapper(
    $this->entityFactory,
    $this->queryExecutor,
    )
    };
    }

    but when I tried to run my code I received this Exception: RuntimeException: "InjectableFactory: Class 'Espo\ORM\Executor\QueryExecutor' does not exist." - but this interface exists and is resolved in any other places .
    Where is the problem? How to fix that?

  • #2
    It's quite complex, to answer this I would need to invest some time, I don't have it.

    You require interfaces in the constructor. You need to bind instances somehow.

    Comment

    Working...
    X