Unable to resolve service "Doctrine\ORM\EntityManager" to a factory; are you certain you provided it during configuration?
Здраствуйте, использую фабрику и пытаюсь передать EntityManager и возникает ошибка. Помогите пожалуйста!
Мой конфиг:
'controllers' => [
'factories' => [
IndexController::class => IndexControllerFactory::class
],
],
Мой controller:
/**
* @var EntityManager
*/
private $entityManager;
/**
* Констурктор
* @param EntityManager $entityManager
*/
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
/**
* HTML страница
* @return ViewModel
*/
public function indexAction()
{
return parent::indexAction(); // TODO: Change the autogenerated stub
}
Моя фабрика:
<?php
namespace Admin\Factory;
use Admin\Controller\IndexController;
use Doctrine\ORM\EntityManager;
use Interop\Container\ContainerInterface;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
class IndexControllerFactory implements FactoryInterface
{
/**
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function __invoke(ContainerInterface $container, $requestedName, ?array $options = null): IndexController
{
$entityManager = $container->get(EntityManager::class);
return new IndexController($entityManager);
}
}