AdobeDocs / AdobeDocs/commerce-php
Issue in /main/src/pages/development/components/routing.md
- Dominant language
- JavaScript
- Stars
- 11
- Forks
- 177
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
Research direction
Open main/src/pages/development/components/routing.md and locate the “Example of routing usage” section. Compare the example with vendor/magento/framework/App/ActionFactory.php, then remove the unused second argument from the ActionFactory::create() call. Done means the example matches the documented method signature and retains the request parameters already set on the request object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 90/100