public function testGetModules() { $manager = new ModuleManager(); $manager->registerModule(new SubModule('sub', 'test')); $manager->registerModule(new AdministrationModule('admin')); $manager->registerModule(new ContentModule('content')); $this->assertCount(3, $manager->getModules()); }
/** * @param string $type * * @return string * * @throws \Exception */ private function lookupEntityName($type) { $module = $this->moduleManager->getModule($type); if (!$module instanceof NodeModuleInterface) { throw new \Exception(sprintf('Type "%s" is not a NodeModule.', $type)); } return $module->getEntityName(); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $data = $builder->getData(); $module = $this->moduleManager->getModule($data['module']); if (!$module instanceof NodeModuleInterface) { return; } $builder->addEventListener(FormEvents::POST_SUBMIT, array($this, 'save')); $builder->addEventListener(FormEvents::PRE_SET_DATA, array($this, 'load')); $builder->get('tabs')->add($this->createTab($builder, 'alias', array('label' => 'Alias'))->add('alias_pattern', 'alias', array('required' => false, 'autofill' => false))); }
/** * @param FrontNodeEvent $event */ public function setTemplate(FrontNodeEvent $event) { $module = $this->moduleManager->getModule($event->getNode()->getType()); if (!$module instanceof NodeModuleInterface) { return; } $template = $module->getDetailTemplate(); if (!$template) { return; } $event->setTemplate($template); }
/** * @param FormEvent $event */ public function load(FormEvent $event) { $data = $event->getData(); $patterns = $this->getRepo()->findAll(); foreach ($this->moduleManager->getContentModules() as $module) { if (!$module instanceof NodeModuleInterface) { continue; } $data[$this->getModuleId($module->getIdentifier())] = '{title}'; foreach ($this->moduleManager->getSubmodules($module->getIdentifier()) as $submodule) { $data[$this->getModuleId($submodule->getIdentifier())] = '{title}'; } } /** @var AliasPattern $pattern */ foreach ($patterns as $pattern) { $data[$this->getModuleId($pattern->getModuleIdentifier())] = $pattern->getPattern(); } $event->setData($data); }