/** * Detects the current region and redirects to the region page * @param \ride\web\cms\Cms $cms Facade to the CMS * @param string $locale Code of the locale * @param string $site Id of the site * @param string $revision Name of the revision * @param string $node Id of the node * @return null */ public function indexAction(Cms $cms, $locale, $site, $revision, $node) { if (!$cms->resolveNode($site, $revision, $node)) { return; } $this->setContentLocale($locale); $cms->setLastAction(self::NAME); $theme = $cms->getTheme($node->getTheme()); $form = $this->buildRegionForm($node, $theme); if ($form->isSubmitted()) { $data = $form->getData(); $region = $data['region']; } else { $region = $cms->getLastRegion(); } if (!$region || $region && !$theme->hasRegion($region)) { $regions = $theme->getRegions(); $region = array_shift($regions); } $this->response->setRedirect($this->getUrl('cms.node.content.region', array('locale' => $locale, 'site' => $site->getId(), 'revision' => $node->getRevision(), 'node' => $node->getId(), 'region' => $region))); }