Example #1
0
 /**
  * Renders and returns output for given view filename with its
  * array of data. Handles parent/extended views.
  *
  * @param string $viewFile Filename of the view
  * @param array $data Data to include in rendered view. If empty the current View::$viewVars will be used.
  * @return string Rendered output
  * @throws CakeException when a block is left open.
  */
 protected function _render($viewFile, $data = array())
 {
     if (empty($data)) {
         $data = $this->viewVars;
     }
     $this->_current = $viewFile;
     $initialBlocks = count($this->Blocks->unclosed());
     $eventManager = $this->getEventManager();
     $beforeEvent = new CakeEvent('View.beforeRenderFile', $this, array($viewFile));
     $eventManager->dispatch($beforeEvent);
     $content = $this->_evaluate($viewFile, $data);
     $afterEvent = new CakeEvent('View.afterRenderFile', $this, array($viewFile, $content));
     $afterEvent->modParams = 1;
     $eventManager->dispatch($afterEvent);
     $content = $afterEvent->data[1];
     if (isset($this->_parents[$viewFile])) {
         $this->_stack[] = $this->fetch('content');
         $this->assign('content', $content);
         $content = $this->_render($this->_parents[$viewFile]);
         $this->assign('content', array_pop($this->_stack));
     }
     $remainingBlocks = count($this->Blocks->unclosed());
     if ($initialBlocks !== $remainingBlocks) {
         throw new CakeException(__d('cake_dev', 'The "%s" block was left open. Blocks are not allowed to cross files.', $this->Blocks->active()));
     }
     return $content;
 }
Example #2
0
 /**
  * Magic accessor for deprecated attributes.
  *
  * @param string $name  Name of the attribute to set.
  * @param mixed  $value Value of the attribute to set.
  *
  * @return mixed
  */
 public function __set($name, $value)
 {
     switch ($name) {
         case 'output':
             return $this->Blocks->set('content', $value);
         default:
             $this->{$name} = $value;
     }
 }