Illuminate\Routing\Router::convertToControllerAction PHP Method

convertToControllerAction() protected method

Add a controller based route action to the action array.
protected convertToControllerAction ( array | string $action ) : array
$action array | string
return array
    protected function convertToControllerAction($action)
    {
        if (is_string($action)) {
            $action = ['uses' => $action];
        }
        // Here we'll merge any group "uses" statement if necessary so that the action
        // has the proper clause for this property. Then we can simply set the name
        // of the controller on the action and return the action array for usage.
        if (!empty($this->groupStack)) {
            $action['uses'] = $this->prependGroupUses($action['uses']);
        }
        // Here we will set this controller name on the action array just so we always
        // have a copy of it for reference if we need it. This can be used while we
        // search for a controller name or do some other type of fetch operation.
        $action['controller'] = $action['uses'];
        return $action;
    }

Usage Example

Example #1
0
 /**
  * Add a controller based route action to the action array.
  *
  * @param  array|string  $action
  * @return array
  */
 protected function convertToControllerAction($action)
 {
     $action = parent::convertToControllerAction($action);
     if ($this->usesActionClass($action)) {
         $action['uses'] = $action['uses'] . '@' . ActionInterface::METHOD_NAME;
         $action['controller'] = $action['uses'];
     }
     return $action;
 }