示例#1
0
 /**
  * @param string $action Action name as lowercase separated string
  * @return string
  */
 public function getActionMethod($action)
 {
     return Str::separatorToCamel($action, '-') . $this->actionMethodSuffix;
 }
 /**
  * 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);
 }
示例#3
0
 /**
  * Filters a full db item array by it's table alias and the strips the table alias.
  *
  * @param array  $rowData
  * @param string $dbTableAlias
  * @param bool   $skipStrip For cases when you want to filter only (no stripping)
  * @return array
  */
 public static function filterStripDbRowData(array $rowData, $dbTableAlias, $skipStrip = false)
 {
     $columnPrefix = $dbTableAlias . '_';
     $filteredAndStrippedRowData = [];
     foreach ($rowData as $key => $val) {
         if (strpos($key, $columnPrefix) === 0) {
             $strippedKey = $skipStrip ? $key : Str::stripLeft($key, $columnPrefix);
             $filteredAndStrippedRowData[$strippedKey] = $val;
         }
     }
     return $filteredAndStrippedRowData;
 }