Pridanie route pomocou route factory cez extension
- duskohu
- Člen | 778
Caute mam nejaku route factory ktora vytvara routu a potreboval by som ju pridat do aktualneho routra. Neviete mi poradit ako na to?
class CmsRouterFactory
{
/** @var EntityManager */
private $em;
/** @var IStorage */
private $cacheStorage;
/** @var LanguageStorage */
private $languageStorage;
/** @var RouterConfiguration */
private $routerConfiguration;
/**
* @param EntityManager $em
* @param IStorage $cacheStorage
* @param LanguageStorage $languageStorage
* @param RouterConfiguration $routerConfiguration
*/
public function __construct(
EntityManager $em,
IStorage $cacheStorage,
LanguageStorage $languageStorage,
RouterConfiguration $routerConfiguration
) {
$this->em = $em;
$this->cacheStorage = $cacheStorage;
$this->languageStorage = $languageStorage;
$this->routerConfiguration = $routerConfiguration;
}
public function create()
{
return new CmsRouter(
$this->em,
$this->cacheStorage,
$this->languageStorage,
$this->routerConfiguration
);
}
}
public function loadConfiguration()
{
// CmsRouterFactory
$builder->addDefinition($this->prefix('cmsRouterFactory'))
->setFactory(CmsRouterFactory::class);
$router = $builder->getDefinition('router');
... @cmsRouterFactory::create
}
Editoval duskohu (6. 6. 2018 11:35)