public static function before() { $args = func_get_args(); if (func_num_args() == 1) { $middleware = array_shift($args); $route = null; } else { list($route, $middleware) = $args; } static::$_container->get('router')->addMiddleware($route, $middleware); }
protected function _runMiddleware($middleware) { $result = false; if (is_string($middleware) && class_exists($middleware, true)) { $middleware = new $middleware($this->_container); } if ($middleware instanceof BaseMiddleware) { $result = $middleware->run(); } if (is_callable($middleware)) { $result = $middleware(); } if ($result) { ob_clean(); $this->_container->get('response')->sendResponse(); die; } }
private function _loadErrorHandler() { if ($this->_container->get('settings')->get('app.debug')) { $whoops = new Run(); $whoops->pushHandler(new PrettyPageHandler()); $whoops->register(); } else { ErrorHandler::register($this->_container->get('logger')); } }
<?php namespace PHPSTORM_META; /** @noinspection PhpUnusedLocalVariableInspection */ /** @noinspection PhpIllegalArrayKeyTypeInspection */ /** @noinspection PhpUndefinedClassInspection */ /** @noinspection PhpDeprecationInspection */ $STATIC_METHOD_TYPES = [\ZigiPhp\Helpers\Collection::get('') => ['app' instanceof ZigiPhp\App, 'settings' instanceof ZigiPhp\Helpers\Config, 'view' instanceof ZigiPhp\Helpers\View, 'logger' instanceof Monolog\Logger, 'router' instanceof ZigiPhp\Http\Router, 'request' instanceof ZigiPhp\Http\Request, 'response' instanceof ZigiPhp\Http\Response]];
protected function _sendBody() { if (!$this->_container->get('request')->isHead()) { echo $this->getBody(); } }