示例#1
0
 /**
  * Generates file for the result view
  *
  * @param Block $block
  * @return string
  * @throws \Exception
  */
 protected function generateResultViewFile(Block $block)
 {
     $filePath = $this->getGeneratedViewsDir() . $block->getRoute() . '.blade.php';
     $fileDirPath = dirname($filePath);
     // Create directory if it does not exist
     if (!is_dir($fileDirPath)) {
         mkdir($fileDirPath, 0755, true);
     }
     try {
         $fileHandle = fopen($filePath, 'w+');
         fwrite($fileHandle, $this->content);
         fclose($fileHandle);
         return $filePath;
     } catch (\Exception $e) {
         throw new \Exception(sprintf('Cannot create view file. Make sure %s dir is writable', $this->getGeneratedViewsDir()));
     }
 }
示例#2
0
文件: Page.php 项目: rogyar/Balcon
 /**
  * Goes recursively trough blocks and attempts to dispatch
  * the specified route
  *
  * @param \Plugins\Cms\Model\Block $block
  * @param string $route
  * @return bool
  */
 protected function routeDispatch(Block $block, $route)
 {
     if (!$this->getDispatchedBlock()) {
         if ($block->getRoute() == $route) {
             // TODO: check if block is routable
             $this->setDispatchedBlock($block);
             $this->isProcessed = true;
             return true;
         } elseif (count($block->getChildren()->getBlocks()) > 0) {
             // Go trough child blocks
             /** @var Block $childBlock */
             foreach ($block->getChildren()->getBlocks() as $childBlock) {
                 $this->routeDispatch($childBlock, $route);
                 if ($this->getDispatchedBlock()) {
                     break;
                 }
             }
         }
     }
     return true;
 }
示例#3
0
 public function getPostInfo(Block $post)
 {
     $customPostParameters = $post->getParams();
     return ['author' => '', 'date' => '', 'title' => $customPostParameters['title'], 'url' => $post->getRoute()];
 }