<?php /** * Grid of users * * @author Anton Shevchuk * @created 02.08.12 18:39 * @return closure */ namespace Application; use Application\Users; use Bluz\Controller\Controller; use Bluz\Proxy\Db; use Bluz\Proxy\Layout; /** * @privilege Management * @return \closure */ return function () { /** * @var Controller $this */ Layout::setTemplate('dashboard.phtml'); Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), __('Users')]); $grid = new Users\Grid(); $grid->setModule($this->module); $grid->setController($this->controller); $this->assign('roles', Db::fetchAll('SELECT * FROM acl_roles')); $this->assign('grid', $grid); };
namespace Application; use Bluz\Controller\Controller; use Bluz\Proxy\Layout; /** * @privilege Info * * @return \closure */ return function () { /** * @var Controller $this */ Layout::title('Routers Map'); Layout::setTemplate('dashboard.phtml'); Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), Layout::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); $controllerInstance = new Controller($module, $controller); $reflection = $controllerInstance->getReflection(); if ($route = $reflection->getRoute()) { if (!isset($routers[$module])) { $routers[$module] = array(); } $routers[$module][$controller] = ['route' => $route, 'params' => $reflection->getParams()]; } } $this->assign('routers', $routers); };
<?php /** * Disable view, like for backbone.js * * @author Anton Shevchuk * @created 22.08.12 17:14 */ namespace Application; use Bluz\Proxy\Layout; return function () { Layout::breadCrumbs([Layout::ahref('Test', ['test', 'index']), 'Without view']); return function () { }; };
<?php /** * Debug bookmarklet * * @author Anton Shevchuk * @created 22.08.12 17:14 */ namespace Application; use Bluz\Controller\Controller; use Bluz\Proxy\Layout; /** * @privilege Info * * @return array */ return function () { /** * @var Controller $this */ Layout::title('Bookmarklets'); Layout::setTemplate('dashboard.phtml'); Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), Layout::ahref('System', ['system', 'index']), __('Bookmarklets')]); $key = getenv('BLUZ_DEBUG_KEY') ?: 'BLUZ_DEBUG'; return ['key' => $key]; };
/** * Example of static route * * @author Anton Shevchuk * @created 12.06.12 13:08 */ namespace Application; use Bluz\Proxy\Layout; use Bluz\Proxy\Request; return function () use($view) { /** * @var Bootstrap $this * @var \Bluz\View\View $view */ Layout::breadCrumbs([Layout::ahref('Test', ['test', 'index']), 'Routers Examples']); $uri = Request::getRequestUri(); $module = Request::getModule(); $controller = Request::getController(); echo <<<CODE <h4>URL: {$uri}</h4> <h4>Route: {$module}/{$controller}</h4> <pre> /** * @route /static-route/ * @route /another-route.html * @return \\closure */ </pre> CODE; return false;
*/ /** * @namespace */ namespace Application; use Bluz\Common\Nil; use Bluz\Controller\Controller; use Bluz\Proxy\Cache; use Bluz\Proxy\Layout; use Bluz\Proxy\Messages; use Bluz\Proxy\Response; /** * Statistics * * @privilege Management * @return void */ return function () { /** * @var Controller $this */ Layout::setTemplate('dashboard.phtml'); Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), Layout::ahref('Cache', ['cache', 'index']), __('Statistics')]); if (!Cache::getInstance() instanceof Nil) { $this->assign('adapter', Cache::getInstance()->getAdapter()); } else { Messages::addNotice("Cache is disabled"); Response::redirectTo('cache', 'index'); } };
<?php /** * Dispatch other controllers * * @author Anton Shevchuk * @created 23.08.12 13:14 */ namespace Application; use Bluz\Proxy\Layout; return function () { /** * @var Bootstrap $this * @var \Bluz\View\View $view */ Layout::breadCrumbs([Layout::ahref('Test', ['test', 'index']), 'Dispatch']); };
<?php /** * PHP Info Wrapper * * @author Anton Shevchuk * @created 22.08.12 17:14 */ namespace Application; use Bluz\Controller\Controller; use Bluz\Proxy\Layout; /** * @privilege Info * * @return \closure */ return function () { /** * @var Controller $this */ Layout::title('PHP Info'); Layout::setTemplate('dashboard.phtml'); Layout::breadCrumbs([Layout::ahref('Dashboard', ['dashboard', 'index']), Layout::ahref('System', ['system', 'index']), __('PHP Info')]); };