예제 #1
0
 protected static function getService()
 {
     //TODO: caching
     $config = Config::get('database');
     $serviceName = $config['service'];
     return Virge::service($serviceName);
 }
예제 #2
0
 /**
  * Listen on the given event, and call our callable
  * @param Event $event
  * @return boolean
  * @throws \RuntimeException
  */
 public function listen(Event $event)
 {
     if (is_callable($this->getCallable())) {
         return call_user_func_array($this->getCallable(), array($event));
     }
     if ($this->getMethod() && ($service = Virge::service($this->getCallable()))) {
         return call_user_func_array(array($service, $this->getMethod()), array($event));
     }
     throw new \RuntimeException(sprintf("Invalid listener: %s, cannot listen on event type: %s", get_class($this), get_class($event)));
 }
예제 #3
0
 /**
  * Route a web request
  */
 public function route($uri = null)
 {
     $request = $this->_buildRequest($uri);
     foreach (Routes::getResolvers() as $resolverConfig) {
         $resolver = $resolverConfig['resolver'];
         if (is_string($resolver) && Virge::service($resolver)) {
             $resolver = Virge::service($resolver);
         }
         $method = $resolverConfig['method'];
         if (false !== ($response = call_user_func_array(array($resolver, $method), array($request)))) {
             if ($response instanceof Response) {
                 $response->send();
             } else {
                 $response = new Response($response);
                 $response->send();
             }
             return true;
         }
     }
     $route = $this->_getRoute($request->getURI());
     if (!$route) {
         throw new NotFoundException();
     }
     if (!$route->access()) {
         throw new UnauthorizedAccessException();
     }
     $route->setActive(true);
     if (is_callable($route->getContoller())) {
         return call_user_func($route->getController(), $request);
     }
     $controllerClassname = $route->getController();
     $controller = new $controllerClassname();
     $method = $route->getMethod();
     $response = call_user_func_array(array($controller, $method), array($request));
     if ($response instanceof Response) {
         $response->send();
     } else {
         $response = new Response($response);
         $response->send();
     }
 }
예제 #4
0
 /**
  * @return ScheduleService
  */
 protected function getScheduleService()
 {
     return Virge::service(ScheduleService::SERVICE_ID);
 }
예제 #5
0
 /**
  * @return TemplateService
  */
 public function getTemplatingService()
 {
     return Virge::service('templating');
 }
예제 #6
0
 protected static function service($serviceId)
 {
     return Virge::service($serviceId);
 }
예제 #7
0
 /**
  * @return ExpressionService
  */
 protected function getExpressionService()
 {
     return Virge::service(ExpressionService::SERVICE_ID);
 }
예제 #8
0
 /**
  * Enter into a service
  * @param string $service
  * @param array $arguments
  */
 protected function entry($service, $method, $arguments)
 {
     return call_user_func_array(array(Virge::service($service), $method), $arguments);
 }
예제 #9
0
 /**
  * @return SchemaService
  */
 protected function getSchemaService()
 {
     return Virge::service('virge/schema');
 }
예제 #10
0
 /**
  * @return QueueService
  */
 protected function getQueueService()
 {
     return Virge::service(QueueService::SERVICE_ID);
 }