/** * Gets all the extra widget URL's * @param array $result Result to add URL's to * @param \ride\library\cms\node\Node $node Node to process * @param string $locale * @param string $nodeUrl * @return array */ protected function getWidgetUrls(array $result, Node $node, $locale, $nodeUrl) { $theme = $this->cms->getTheme($node->getTheme()); $regions = $theme->getRegions(); foreach ($regions as $region => $null) { $sections = $node->getSections($region); foreach ($sections as $section => $layout) { $widgets = $node->getWidgets($region, $section); foreach ($widgets as $block => $widgets) { foreach ($widgets as $widgetId => $widget) { $widget = $this->cms->getWidget($widget); if (!$widget) { continue; } $widget = clone $widget; $widget->setIdentifier($widgetId); $widget->setRegion($region); $widget->setSection($section); $widget->setBlock($block); $widget->setProperties($node->getWidgetProperties($widgetId)); $widget->setLocale($locale); $routes = $widget->getRoutes(); if (!$routes) { continue; } foreach ($routes as $route) { $path = $route->getPath(); $pathTokens = $route->getPathTokens(); foreach ($pathTokens as $token) { if (substr($token, 0, 1) == '%' && substr($token, -1) == '%') { $path = str_replace($token, '*', $path); } } $result[] = $nodeUrl . $path; } } } } } return $result; }
/** * Resolves the provided region * @param \ride\library\cms\node\Node $node * @param string $locale Code of the locale * @param string $region Machine name of the region * @param string $theme Machine name of the theme * @return boolean True when the region is available in the provided node, * false if the region is not available, the response code will be set to * 404 */ public function resolveRegion(Node $node, $locale, $region, &$theme = null) { try { $theme = $node->getTheme(); $theme = $this->themeModel->getTheme($theme); if (!$theme->hasRegion($region)) { throw new CmsException(); } } catch (CmsException $exception) { return false; } return true; }