private function createFinalResponse(Layout $layout) { return $this->createResponse('Can\'t create children of ' . $layout->getLabel() . ' layout', 403); }
/** * Sets the layout for the page. * Adds as much ContentSet to the page main ContentSet than defined zones in layout. * * @param Layout $layout * @param AbstractClassContent $toPushInMainZone * * @return Page */ public function setLayout(Layout $layout, AbstractClassContent $toPushInMainZone = null) { $this->_layout = $layout; $count = count($layout->getZones()); // Add as much ContentSet to the page main ContentSet than defined zones in layout for ($i = $this->getContentSet()->count(); $i < $count; $i++) { // Do this case really exists ? if (null === ($zone = $layout->getZone($i))) { $this->getContentSet()->push(new ContentSet()); continue; } // Create a new column $contentset = new ContentSet(null, $zone->options); if (null !== $toPushInMainZone && true === $zone->mainZone) { // Existing content push in the main zone $contentset->push($toPushInMainZone->setMainNode($this)); } elseif ('inherited' === $zone->defaultClassContent) { // Inherited zone => same ContentSet than parent if exist $contentset = $this->getInheritedContent($i, $contentset); } elseif ($zone->defaultClassContent) { // New default content push $contentset->push($this->createNewDefaultContent('BackBee\\CoreDomain\\ClassContent\\' . $zone->defaultClassContent, $zone->mainZone)); } $this->getContentSet()->push($contentset); } return $this; }
protected function computeTemplate(Layout $layout, $value) { if ($value !== null) { if (strlen(pathinfo($value, PATHINFO_EXTENSION)) !== 0) { $layout->setPath($value); } else { throw new \Exception('Invalid template name for ' . $layout->getLabel() . ' layout.'); } } }
/** * Return the file path to current layout, try to create it if not exists. * * @param Layout $layout * * @return string the file path * * @throws RendererException */ protected function getLayoutFile(Layout $layout) { $layoutfile = $layout->getPath(); if (null === $layoutfile && 0 < $this->manageableExt->count()) { $adapter = null; if (null !== $this->defaultAdapter && null !== ($adapter = $this->rendererAdapters->get($this->defaultAdapter))) { $extensions = $adapter->getManagedFileExtensions(); } else { $extensions = $this->manageableExt->keys(); } if (0 === count($extensions)) { throw new RendererException('Declared adapter(s) (count:' . $this->rendererAdapters->count() . ') is/are not able to manage ' . 'any file extensions at moment.'); } $layoutfile = StringUtils::toPath($layout->getLabel(), array('extension' => reset($extensions))); $layout->setPath($layoutfile); } return $layoutfile; }
public function removeThumbnail(Layout $layout, BBApplication $app) { $thumbnailfile = $layout->getPicPath(); if (empty($thumbnail)) { return true; } File::resolveFilepath($thumbnailfile, null, array('include_path' => $app->getResourceDir())); while (true === is_file($thumbnailfile) && true === is_writable($thumbnailfile)) { @unlink($thumbnailfile); $thumbnailfile = $layout->getPicPath(); File::resolveFilepath($thumbnailfile, null, array('include_path' => $app->getResourceDir())); } return true; }
/** * Return the file path to current layout, try to create it if not exists. * * @param Layout $layout * * @return string the file path * * @throws RendererException */ protected function getLayoutFile(Layout $layout) { $layoutfile = $layout->getPath(); if (null === $layoutfile && 0 < count($this->_includeExtensions)) { $ext = reset($this->_includeExtensions); $layoutfile = StringUtils::toPath($layout->getLabel(), array('extension' => $ext)); $layout->setPath($layoutfile); } return $layoutfile; }