Пример #1
0
 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);
 }
Пример #2
0
 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;
     }
 }
Пример #3
0
 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'));
     }
 }
Пример #4
0
<?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]];
Пример #5
0
 protected function _sendBody()
 {
     if (!$this->_container->get('request')->isHead()) {
         echo $this->getBody();
     }
 }