/** * Returns the URI of the icon of the provided content. * * @param AbstractContent $content The content. * * @return string|null The icon URL if found, null otherwise. */ public function getIcon(AbstractContent $content) { if (null === ($baseFolder = $this->getBaseFolder())) { return null; } $defaultImage = $content->getDefaultImageName(); if ('/' === substr($defaultImage, 0, 1)) { $iconUrl = $defaultImage; $urlType = RouteCollection::IMAGE_URL; } else { $iconUrl = $this->resolveResourceThumbnail($defaultImage); $urlType = RouteCollection::RESOURCE_URL; } return $this->application->getRouting()->getUri($iconUrl, null, null, $urlType); }
/** * Initializes application with the provided themes. * * @param ThemeInterface|null $theme */ protected function initializeTheme(ThemeInterface $theme = null) { if (null === $theme) { return; } $layoutDir = $theme->getLayoutDir(); if (false != $layoutDir && is_dir($layoutDir)) { $this->app->getRenderer()->addLayoutDir($layoutDir); } $viewDir = $theme->getViewDir(); if (false != $viewDir && is_dir($viewDir)) { $this->app->getRenderer()->addScriptDir($viewDir); } $helperDir = $theme->getHelperDir(); if (false != $helperDir && is_dir($helperDir)) { $this->app->getRenderer()->addHelperDir($helperDir); } $routing = $this->app->getRouting(); if ($routing instanceof RouteCollection) { $staticDir = $this->app->getContainer()->getParameter('theme.static.dir'); $staticDir = realpath($staticDir . DIRECTORY_SEPARATOR . $theme->getName()); if (false !== $staticDir) { $routing->setStaticDir($staticDir); } } }
/** * CategoryManager's constructor. * * @param ApplicationInterface $application application from where we will extract classcontent's categories */ public function __construct(ApplicationInterface $application) { $this->categories = []; $this->options = ['thumbnail_url_pattern' => $application->getRouting()->getUrlByRouteName('bb.classcontent_thumbnail', ['filename' => '%s.' . $application->getContainer()->getParameter('classcontent_thumbnail.extension')])]; $this->loadCategoriesFromClassContentDirectories($application->getClassContentDir()); }