I am trying to implement Magento 2 Coding Standard so I found an Article Here -> https://community.magento.com/t5/Magento-DevBlog/Decomposition-of-Magento-Controllers/ba-p/430883
I have changed my frontend And backend Controllers in the same way
Here is an Example
Frontend Controller:
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\Controller\Result\RedirectFactory;
class HomeRedirect implements HttpGetActionInterface
{
private RedirectFactory $redirectFactory;
/**
* @param RedirectFactory $redirectFactory
*/
public function __construct(
RedirectFactory $redirectFactory
) {
$this->redirectFactory = $redirectFactory;
}
/**
* Check is Allowed
* @return bool
*/
protected function _isAllowed()
{
return true;
}
public function execute()
{
$this->redirectFactory->create()->setPath('dashboard');
}
}
, in the same way, I am have implemented an admin controller
use Magento\Backend\Model\View\Result\Forward;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Backend\Model\View\Result\ForwardFactory;
class NewAction implements HttpGetActionInterface
{
private ForwardFactory $forwardFactory;
/**
* @param ForwardFactory $forwardFactory
*/
public function __construct(
ForwardFactory $forwardFactory
) {
$this->forwardFactory = $forwardFactory;
}
/**
* @return Forward
*/
public function execute()
{
return $this->forwardFactory->create()->forward('edit');
}
}
Is this right way to do so?
Anyone, please suggest to me any Module in which the composition is implemented on controllers properly