getRouteUrl() public method

public getRouteUrl ( Node | integer $nodeOrId, boolean $suppressStartNodeCheck = false ) : string
$nodeOrId Jarves\Model\Node | integer
$suppressStartNodeCheck boolean
return string
Example #1
0
 public function registerPluginRoutes(Node $page)
 {
     $domain = $this->pageStack->getDomain($page->getDomainId());
     $this->stopwatch->start('Register Plugin Routes');
     //add all router to current router and fire sub-request
     $cacheKey = 'core/node/plugins-' . $page->getId();
     $plugins = $this->cacher->getDistributedCache($cacheKey);
     if (null === $plugins) {
         $plugins = ContentQuery::create()->filterByNodeId($page->getId())->filterByType('plugin')->find();
         $this->cacher->setDistributedCache($cacheKey, serialize($plugins));
     } else {
         $plugins = unserialize($plugins);
     }
     /** @var $plugins Content[] */
     foreach ($plugins as $plugin) {
         if (!$plugin->getContent()) {
             continue;
         }
         $data = json_decode($plugin->getContent(), true);
         if (!$data) {
             $this->logger->alert(sprintf('On page `%s` [%d] is a invalid plugin `%d`.', $page->getTitle(), $page->getId(), $plugin->getId()));
             continue;
         }
         $bundleName = isset($data['module']) ? $data['module'] : @$data['bundle'];
         $config = $this->jarves->getConfig($bundleName);
         if (!$config) {
             $this->logger->alert(sprintf('Bundle `%s` for plugin `%s` on page `%s` [%d] does not not exist.', $bundleName, @$data['plugin'], $page->getTitle(), $page->getId()));
             continue;
         }
         $pluginDefinition = $config->getPlugin(@$data['plugin']);
         if (!$pluginDefinition) {
             $this->logger->alert(sprintf('In bundle `%s` the plugin `%s` on page `%s` [%d] does not not exist.', $bundleName, @$data['plugin'], $page->getTitle(), $page->getId()));
             continue;
         }
         if ($pluginRoutes = $pluginDefinition->getRoutes()) {
             foreach ($pluginRoutes as $idx => $route) {
                 $controller = $pluginDefinition->getController();
                 $defaults = array('_controller' => $route->getController() ?: $controller, '_jarves_is_plugin' => true, '_content' => $plugin, '_title' => sprintf('%s: %s', $bundleName, $pluginDefinition->getLabel()), 'options' => isset($data['options']) && is_array($data['options']) ? $data['options'] : [], 'jarvesFrontend' => true, 'nodeId' => $page->getId());
                 if ($route->getDefaults()) {
                     $defaults = array_merge($defaults, $route->getArrayDefaults());
                 }
                 $url = $this->pageStack->getRouteUrl($page->getId());
                 $this->routes->add('jarves_frontend_plugin_' . ($route->getId() ?: $plugin->getId()) . '_' . $idx, new SyRoute($url . '/' . $route->getPattern(), $defaults, $route->getArrayRequirements() ?: array(), [], '', [], $route->getMethods() ?: []));
             }
         }
     }
     $this->stopwatch->stop('Register Plugin Routes');
 }