'personal'), 'personal') * addConditionGet(array('module' => 'login'), 'login') */ public function addConditionGet($get, Filter $layout) { $this->addCondition(Functions::rcurry(array($this, 'checkGet'), $get), $layout); } /** * Условие для аякс запросов. Тоже самое что и addConditionGet но еще проверяется является ли запрос ajax */ public function addConditionXHR($get, Filter $layout) { $this->addCondition(Functions::rcurry(array($this, 'checkXHR'), $get), $layout); } public function checkGet(/*.HttpRequest.*/$request, $get) { if (is_array($get)) { foreach ($get as $key => $value) { if ($request->get($key) != $value) { return false; } } } return true; } public function checkXHR(/*.HttpRequest.*/$request, $get) { return $request->isAjax() && $this->checkGet($request, $get); } /** * Добавляет условие в общем виде * @parma $get function(HttpRequest) Функция * @parma $layout Layout Макет */ public function addCondition($get, Filter $layout) { $this->condition [] = array($get, $layout); } /** * Выбирает и применяет макет для страницы */ public function execute(HttpRequest $request) { // print_r($request->get('mode')); foreach ($this->condition as $condition) { if (call_user_func($condition[0], $request)) { $layout = $condition[1]; $view = $layout->execute($request); if (is_object($view)) { echo $view->render(); } else { echo $view; } return null; } } } }