Skip to content

Issue in /main/src/pages/development/components/routing.md #457

Description

@NguyenVanNam-Dev

In the Routing documentation under the "Example of routing usage" section, the custom Router class example passes a second argument to ActionFactory::create():

return $this->actionFactory->create(Forward::class, ['request' => $request]);

However, Magento\Framework\App\ActionFactory::create() only accepts a single parameter ($actionName). The second argument ['request' => $request] is never used.

Reference:
vendor/magento/framework/App/ActionFactory.php

public function create($actionName)
{
if (!is_subclass_of($actionName, \Magento\Framework\App\ActionInterface::class)) {
throw new \InvalidArgumentException(
'The action name provided is invalid. Verify the action name and try again.'
);
}
return $this->_objectManager->create($actionName);
}

Suggested fix:

return $this->actionFactory->create(Forward::class);

The request parameters (moduleName, controllerName, actionName) are already set on the $request object prior to this line, so the Forward action will read them from the request directly. No additional constructor arguments are needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions