/** * Build list of custom routers * * @author Anton Shevchuk * @created 12.06.12 12:27 */ namespace Application; use Bluz\Proxy\Layout; return function () use($view) { /** * @var Bootstrap $this * @var \Bluz\View\View $view */ Layout::title('Routers Map'); Layout::setTemplate('dashboard.phtml'); Layout::breadCrumbs([$view->ahref('Dashboard', ['dashboard', 'index']), $view->ahref('System', ['system', 'index']), __('Routers Map')]); $routers = array(); foreach (new \GlobIterator(PATH_APPLICATION . '/modules/*/controllers/*.php') as $file) { $module = pathinfo(dirname(dirname($file->getPathname())), PATHINFO_FILENAME); $controller = pathinfo($file->getPathname(), PATHINFO_FILENAME); $reflection = $this->reflection($file->getPathname()); if ($route = $reflection->getRoute()) { if (!isset($routers[$module])) { $routers[$module] = array(); } $routers[$module][$controller] = ['route' => $route, 'params' => $reflection->getParams()]; } } $view->routers = $routers; };
<?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ /** * @namespace */ namespace Bluz\Controller\Helper; use Bluz\Application\Application; use Bluz\Controller\Controller; use Bluz\Proxy\Layout; /** * Switch layout * * @param $layout */ return function ($layout) { /** * @var Controller $this */ Application::getInstance()->useLayout(true); Layout::setTemplate($layout); };
/** * Set Layout template and/or flag * @api * @param bool|string $flag * @return void */ public function useLayout($flag = true) { if (is_string($flag)) { Layout::setTemplate($flag); $this->layoutFlag = true; } else { $this->layoutFlag = $flag; } }
* Create of CRUD * * @category Application * * @author dark * @created 14.05.13 10:50 */ namespace Application; use Bluz\Proxy\Layout; use Bluz\Proxy\Request; use Bluz\Validator\Exception\ValidatorException; return function () use($view) { /** * @var Bootstrap $this */ Layout::setTemplate('small.phtml'); $row = new Test\Row(); $view->row = $row; if (Request::isPost()) { $crud = Test\Crud::getInstance(); try { $crud->createOne(Request::getPost()); } catch (ValidatorException $e) { $row = $crud->readOne(null); $row->setFromArray(Request::getPost()); $result = ['row' => $row, 'errors' => $e->getErrors(), 'method' => Request::METHOD_POST]; } // TODO: example without AJAX calls } };