Mapper Factory with Dependency Injection exception

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kacper
    Junior Member
    • Oct 2023
    • 29

    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?
  • yuri
    Member
    • Mar 2014
    • 8669

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

    Working...