Exemple #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);
 }
Exemple #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;
     }
 }
Exemple #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'));
     }
 }
Exemple #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]];
Exemple #5
0
 protected function _sendBody()
 {
     if (!$this->_container->get('request')->isHead()) {
         echo $this->getBody();
     }
 }