示例#1
0
 public function __construct()
 {
     $this->watch = new Stopwatch();
     $this->watch->start('rendering');
     // initialize start time
     $this->start_time = microtime(true);
     // Initialize all parameters before parsing url
     Loader::Init();
     // get DI container
     if (DEVELOPMENT_ENVIRONMENT) {
         $this->watch->start('enable_container');
     }
     $this->container = ServiceProvider::GetDependencyContainer();
     if (DEVELOPMENT_ENVIRONMENT) {
         $event = $this->watch->stop('enable_container');
         $start_container = ($event->getOrigin() + $event->getStartTime()) / 1000;
         $stop_container = ($event->getOrigin() + $event->getEndTime()) / 1000;
         \Debug::addMeasure("Enable container", $start_container, $stop_container);
     }
     \Debug::startMeasure('load_filter', 'Load filters');
     // instantiate filters object
     $this->filters = new Filters();
     \Debug::stopMeasure('load_filter');
     // enable error reporting
     $this->setReporting();
 }
示例#2
0
文件: Router.php 项目: kletellier/mvc
 public function __construct(\Symfony\Component\HttpFoundation\Request $request = null)
 {
     $this->_route = "";
     $this->_controller = "";
     $this->_method = "";
     $this->_args = array();
     $this->_container = \GL\Core\DI\ServiceProvider::GetDependencyContainer();
     $req = $request != null ? $request : $this->_container->get('request');
     $this->_request = $req;
 }
示例#3
0
文件: Facade.php 项目: kletellier/mvc
 protected static function resolveFacadeInstance($name)
 {
     if (is_object($name)) {
         return $name;
     }
     if (isset(static::$resolvedInstance[$name])) {
         return static::$resolvedInstance[$name];
     }
     return static::$resolvedInstance[$name] = \GL\Core\DI\ServiceProvider::GetDependencyContainer()->get($name);
 }
示例#4
0
 public function collect()
 {
     $redis = \GL\Core\DI\ServiceProvider::GetDependencyContainer()->get('redis');
     $commands = $redis->getCommandsHistory();
     $data = array();
     $i = 1;
     foreach ($commands as $value) {
         $data[$i] = "Method " . strtoupper($value['command']) . "  :: Parameters " . $this->getDataFormatter()->formatVar($value['parameters']);
         $i++;
     }
     return $data;
 }
示例#5
0
文件: Utils.php 项目: kletellier/mvc
 private static function getContainer()
 {
     return \GL\Core\DI\ServiceProvider::GetDependencyContainer();
 }
示例#6
0
 function __construct()
 {
     $this->_container = \GL\Core\DI\ServiceProvider::GetDependencyContainer();
 }
示例#7
-1
文件: Utils.php 项目: kletellier/mvc
 /**
  * Get Url from routename and parameters array
  * @param string $routename route name defined in routes.yml
  * @param array $params parameters array
  * @return string url
  */
 public static function route($routename, $params = array())
 {
     $url = "";
     try {
         $rc = \GL\Core\DI\ServiceProvider::GetDependencyContainer()->get('routes');
         $route = $rc->get($routename);
         if ($route != null) {
             $pattern = $route->getPath();
             $url = \GL\Core\Helpers\Utils::url($pattern);
             $urlo = S::create($url);
             $sep = "/";
             $defaults = $route->getDefaults();
             $param_array = array_merge($defaults, $params);
             foreach ($param_array as $key => $value) {
                 $str = '{' . $key . '}';
                 $urlo = $urlo->replace($str, $value);
             }
             $urlo = $urlo->removeRight($sep);
         }
     } catch (Exception $e) {
         $urlo = S::create("");
     }
     $ret = isset($urlo) == true ? $urlo->__toString() : "";
     return $ret;
 }