Beispiel #1
0
 /**
  * Test to see if the current payload is dispatchable.
  *
  * This method iterates through all of the controller maps
  * and checks to see if the class can be instantiated and the
  * action executed.
  *
  * This method will actually store an instantiated controller
  * within the $class property of this Dispatch object.
  *
  * @return bool
  */
 public function isDispatchable()
 {
     $this->module = $this->payload->has('module') ? ucfirst(strtolower($this->payload->get('module'))) : '';
     $this->controller = $this->payload->has('controller') ? ucfirst(strtolower($this->payload->get('controller'))) : '';
     $this->action = $this->payload->has('action') ? $this->payload->get('action') : '';
     foreach ($this->controllerMaps as $map) {
         $this->class = str_replace([':module', ':controller'], [$this->module, $this->controller], $map);
         if (class_exists($this->class)) {
             $this->class = new $this->class($this->assets);
             if ($this->class instanceof \Proem\Controller\Template) {
                 if (is_callable([$this->class, $this->action . 'Action'])) {
                     return true;
                 }
             }
         }
     }
     return false;
 }