public function handleAttached(Form $form) { $path = $this->moduleHelpers->expandPath($form->data, 'Resources/layouts'); $type = $this->getTypeByKey($form->data); if ($path && !is_writable($path)) { $form->addError("File '{$path}' is not writable."); } if ($form->data && $type === self::TYPE_TEMPLATE) { $module = $this->getModuleByKey($form->data); $form['layout']->setItems(array_keys($this->templateManager->getLayoutsByModule($module)), FALSE)->setPrompt('-- All --'); } }
/** * @param IModule $module */ public function uninstall(IModule $module) { if (!$this->context->hasService('doctrine') || !$this->context->doctrine->createCheckConnection()) { throw new \Exception('Database connection not found!'); } $layouts = $this->templateManager->getLayoutsByModule($module->getName()); $repository = $this->getTemplateRepository(); foreach ($layouts as $path => $name) { foreach ($repository->findBy(array('file' => $path)) as $entity) { $repository->delete($entity); } } }
public function getTemplates() { $data = array(); foreach ($this->presenter->context->parameters['modules'] as $moduleName => $val) { if (!count($this->templateManager->getLayoutsByModule($moduleName))) { continue; } $item = array('title' => $moduleName, 'key' => $moduleName, 'isFolder' => TRUE, 'isLazy' => TRUE); if ($this->getState($moduleName)) { $item['expand'] = TRUE; } $data2 = array(); foreach ($this->templateManager->getLayoutsByModule($moduleName) as $name => $key) { $s = array('isFolder' => TRUE, 'title' => '@' . $name . ' <small class="muted">' . $this->template->translate('layout') . '</small>', 'key' => $key); foreach ($this->templateManager->getTemplatesByModule($moduleName, $name) as $name => $key) { $item2 = array('title' => $name . ' <small class="muted">' . $this->template->translate('template') . '</small>', 'key' => $key); $s['children'][] = $item2; } if ($this->getState($key)) { $s['expand'] = TRUE; } $data2[] = $s; } foreach ($this->templateManager->getTemplatesByModule($moduleName) as $name => $key) { $data2[] = array('title' => $name . ' <small class="muted">' . $this->template->translate('template') . '</small>', 'key' => $key); } $item['children'] = $data2; $data[] = $item; } return $data; }
public function handleAttached(Form $form) { $presenters = array(); foreach ($form->presenter->context->findByTag('presenter') as $name => $item) { if (substr($name, -7) === 'Factory') { $name = substr($name, 0, -7); } $presenter = $this->presenterFactory->formatPresenterFromServiceName($name); $class = $this->presenterFactory->getPresenterClass($presenter); if (!is_subclass_of($class, '\\CmsModule\\Content\\Presenters\\PagePresenter')) { continue; } $name = substr($name, 0, -9); $name = explode('.', $name); $name = implode(':', $name); $presenters[$name] = $name; } $components = array(); foreach ($this->widgetManager->getWidgets() as $name => $factory) { $components[$factory['class']] = ucfirst($name) . 'Control'; } $form['presenter']->setItems($presenters); $form['component']->setItems($components); $module = $form['target']->value ? $form['target']->value : key($this->modules); $form['layout']->setItems(array_keys($this->templateManager->getLayoutsByModule($module)), FALSE)->setDisabled(FALSE)->setPrompt('-- All --'); }