Add namespace.
This commit is contained in:
28
Layout/ErrorLayout.php
Normal file
28
Layout/ErrorLayout.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php namespace Majestic\Layout;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage Layout
|
||||
* @since 2010-02-25
|
||||
*/
|
||||
|
||||
class ErrorLayout extends Layout
|
||||
{
|
||||
/**
|
||||
* @var \Majestic\ExceptionGeneralException
|
||||
*/
|
||||
protected $exception;
|
||||
|
||||
protected function execute()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Exception $exception
|
||||
*/
|
||||
public function setException(\Exception $exception)
|
||||
{
|
||||
$this->exception = $exception;
|
||||
}
|
||||
}
|
77
Layout/Layout.php
Normal file
77
Layout/Layout.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php namespace Majestic\Layout;
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
* @package Majestic
|
||||
* @subpackage Layout
|
||||
* @since 2010-02-25
|
||||
*/
|
||||
|
||||
abstract class Layout
|
||||
{
|
||||
|
||||
protected $template;
|
||||
|
||||
/**
|
||||
* @var \Majestic\View\PHPView
|
||||
*/
|
||||
protected $view;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->view = \Majestic\App\FrontController::getInstance()->getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \Majestic\App\Action $action
|
||||
*/
|
||||
protected function assign($name, $action)
|
||||
{
|
||||
$this->view->assign($name, $action->fetch());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \Majestic\App\Action $action
|
||||
*/
|
||||
protected function append($name, $action)
|
||||
{
|
||||
$this->view->append($name, $action->fetch());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @param \Majestic\App\Action $action
|
||||
*/
|
||||
protected function prepend($name, $action)
|
||||
{
|
||||
$this->view->prepend($name, $action->fetch());
|
||||
}
|
||||
|
||||
abstract protected function execute();
|
||||
|
||||
/**
|
||||
* Execute Action, insert action's result html into layout template and return Layout html
|
||||
* @param \Majestic\App\Action $action
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($action)
|
||||
{
|
||||
$this->view->assign('content', $action->fetch());
|
||||
$this->execute();
|
||||
return $this->view->fetch($this->getTemplate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return content of template
|
||||
* @return string
|
||||
*/
|
||||
protected function getTemplate()
|
||||
{
|
||||
$template = ($this->template) ? $this->template : substr(get_class($this), 0, -6/*strlen('Layout')*/);
|
||||
return '/layouts/' . $template;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user