/**
  * Dispatch the requested action
  *
  * @param string $action action id/name (lowercase, - word separation)
  * @param array  $actionArgs
  * @return Response
  * @throws Routing\Exception\ResourceNotFoundException
  */
 public function dispatch($action = '', array $actionArgs = [])
 {
     // If not special action is provided, try to get from request attribute
     $action = Str::camelToSeparator($action ?: $this->request->attributes->get('action'), '-');
     $actionMethod = $this->app->getRouter()->getActionMethod($action);
     $collectedArgs = $this->getCollectedDispatchArgs($actionMethod, $actionArgs);
     // Call pre dispatch method and return it's response if there is one (uncommon)
     $preDispatchResponse = $this->preDispatch($action);
     if ($preDispatchResponse instanceof Response) {
         return $preDispatchResponse;
     }
     // Call action method
     $actionResponse = call_user_func_array([$this, $actionMethod], $collectedArgs);
     $this->postDispatch();
     return $this->getDispatchResponse($action, $actionResponse);
 }
示例#2
0
 /**
  * Get raw (with underscore as word separator as it is formatted in database)
  * field name from a object field property name (camelcased).
  *
  * @param string $propertyName
  * @return string
  */
 public static function getDbFieldName($propertyName)
 {
     if (!isset(self::$cachedDbFieldNames[$propertyName])) {
         self::$cachedDbFieldNames[$propertyName] = Str::camelToSeparator($propertyName);
     }
     return self::$cachedDbFieldNames[$propertyName];
 }