示例#1
0
文件: Route.php 项目: zigiphp/zigiphp
 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
文件: App.php 项目: zigiphp/zigiphp
 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
 /**
  * @param string $sql
  * @param array  $binding
  *
  * @return BaseModel[]|Collection
  */
 public static function findAll($sql = null, $binding = [])
 {
     $model = new static();
     $result = R::findAll($model->_table, $sql, $binding);
     $collection = new Collection();
     foreach ($result as $key => $bean) {
         $innerModel = new static();
         $innerModel->_bean = $bean;
         $collection->set($key, $innerModel);
     }
     return $collection;
 }
示例#5
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]];
示例#6
0
 protected function _sendBody()
 {
     if (!$this->_container->get('request')->isHead()) {
         echo $this->getBody();
     }
 }