Esempio n. 1
1
 /**
  * Handles a Request to convert it to a Response.
  *
  * When $catch is true, the implementation must catch all exceptions
  * and do its best to convert them to a Response instance.
  *
  * @param Request $request  A Request instance
  * @param integer $type     The type of the request
  *                          (one of HttpKernelInterface::MASTER_REQUEST
  *                          or HttpKernelInterface::SUB_REQUEST)
  * @param Boolean $catch    Whether to catch exceptions or not
  *
  * @return Response A Response instance
  *
  * @throws \Exception When an Exception occurs during processing
  *
  * @api
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     //Start listening for resource uri generation requests
     $generator = new ResourceGenerator($this, $request);
     static::$dispatcher = new EventDispatcher();
     //Listen in for resource generate requests
     static::$dispatcher->addListener(self::EVENT_RESOURCE_GENERATE, [$generator, 'processEvent']);
     if ($this->isDispatchRequest($request)) {
         //Process the response for a dispatchable
         return $this->getResponseForPath($this->getDispatchablePath($request), $request);
     } else {
         //Handle to request through the next/final app
         return $this->_app->handle($request, $type, $catch);
     }
 }
Esempio n. 2
0
 public static function unsetEventDispatcher()
 {
     static::$dispatcher = null;
 }
Esempio n. 3
0
File: Move.php Progetto: yajra/baum
 /**
  * Set the event dispatcher instance.
  *
  * @param  \Illuminate\Events\Dispatcher
  * @return void
  */
 public static function setEventDispatcher(Dispatcher $dispatcher)
 {
     static::$dispatcher = $dispatcher;
 }
Esempio n. 4
0
 /**
  * Set the event dispatcher instance.
  *
  * @param  \Illuminate\Events\Dispatcher  $dispatcher
  * @return void
  */
 public static function setEventDispatcher(\Illuminate\Events\Dispatcher $dispatcher)
 {
     static::$dispatcher = $dispatcher;
 }
Esempio n. 5
0
 public static function clear()
 {
     static::$dispatcher = null;
 }
Esempio n. 6
0
 public static function boot()
 {
     parent::boot();
     // Mock a dispatcher
     $dispatcher = M::mock('OBEventDispatcher');
     $dispatcher->shouldReceive('listen')->andReturnUsing(function ($event, $callback) {
         static::$listenerStub[$event] = $callback;
     });
     $dispatcher->shouldReceive('until')->andReturnUsing(function ($event, $model) {
         if (isset(static::$listenerStub[$event]) and strpos(static::$listenerStub[$event], '@') !== false) {
             list($listener, $method) = explode('@', static::$listenerStub[$event]);
             if (isset(static::$listenerStub[$event])) {
                 call_user_func([$listener, $method], $model);
             }
         } elseif (isset(static::$listenerStub[$event])) {
             call_user_func(static::$listenerStub[$event], $model);
         }
     });
     $dispatcher->shouldReceive('fire')->andReturnUsing(function ($event, $model) {
         if (isset(static::$listenerStub[$event]) and strpos(static::$listenerStub[$event], '@') !== false) {
             list($listener, $method) = explode('@', static::$listenerStub[$event]);
             if (isset(static::$listenerStub[$event])) {
                 call_user_func([$listener, $method], $model);
             }
         } elseif (isset(static::$listenerStub[$event])) {
             call_user_func(static::$listenerStub[$event], $model);
         }
     });
     static::$dispatcher = $dispatcher;
 }
Esempio n. 7
0
 protected static function boot()
 {
     parent::boot();
     !static::$dispatcher and static::$dispatcher = new Illuminate\Events\Dispatcher();
 }
 public static function reset()
 {
     static::$dispatcher = null;
 }
Esempio n. 9
0
 /**
  * Sets the event dispatcher status.
  *
  * @param  bool $status
  * @return $this
  */
 public static function setDispatcherStatus($status)
 {
     static::$dispatcher = (bool) $status;
     return static::class;
 }