/** * Returns a list of all elements of the given type * * @param $elementType * * @return string */ public function elementsOverviewAction($elementType) { try { $elementReferences = array_map(function (Element $element) { return $element->getReference(); }, $this->elementTypesModel->getListedElements($elementType)); return $this->twig->render("@core/elements_overview_page.twig", ["elementReferences" => $elementReferences]); } catch (\InvalidArgumentException $e) { throw new NotFoundHttpException("Unknown element type '{$elementType}'.", $e); } }
/** * Registers all models and all twig layout namespaces * * @param string $baseDir */ private function registerModelsAndTwigLayoutNamespaces($baseDir) { $elementTypesModel = new ElementTypesModel($baseDir); // model $this["model.element_types"] = $elementTypesModel; $this["model.download"] = new DownloadModel($baseDir); // twig template namespaces foreach ($elementTypesModel->getAllElementTypes() as $elementType) { $this["twig.loader.filesystem"]->addPath($elementTypesModel->getUserSubDirectory("{$elementType}s"), $elementType); } $this["twig.loader.filesystem"]->addPath($elementTypesModel->getUserSubDirectory("_base"), "base"); }