Example of usage use Bluz\Proxy\HttpCacheControl;
See also: Instance::setPrivate()
See also: Instance::setPublic()
See also: Instance::getMaxAge()
See also: Instance::getMaxAge()
See also: Instance::getMaxAge()
See also: Instance::getTtl()
See also: Instance::setTtl()
See also: Instance::setClientTtl()
See also: Instance::getEtag()
See also: Instance::setEtag()
See also: Instance::getAge()
See also: Instance::setAge()
See also: Instance::getExpires()
See also: Instance::setExpires()
See also: Instance::getLastModified()
See also: Instance::setLastModified()
Author: Anton Shevchuk
Inheritance: use trait ProxyTrait
Beispiel #1
0
 */
namespace Application;

use Bluz\Application\Exception\NotFoundException;
use Bluz\Proxy\HttpCacheControl;
use Bluz\Proxy\Layout;
use Bluz\View\View;
return function ($alias) use($view) {
    /**
     * @var Bootstrap $this
     * @var View $view
     * @var Pages\Row $page
     */
    $page = Pages\Table::getInstance()->getByAlias($alias);
    if (!$page) {
        // throw NOT FOUND exception
        // all logic of error scenario you can found in default error controller
        // see /application/modules/error/controllers/index.php
        throw new NotFoundException();
    } else {
        // setup HTML layout data
        Layout::title(esc($page->title), View::POS_PREPEND);
        Layout::meta('keywords', esc($page->keywords));
        Layout::meta('description', esc($page->description));
        // setup HTTP cache
        HttpCacheControl::setPublic();
        HttpCacheControl::setLastModified($page->updated);
        // assign page to view
        $view->page = $page;
    }
};