Hello Magento folks,
Magento 2 is the ultimate existence of the leading enterprise for Ecommerce platforms and has been used by over 200,000 online retailers. Basically, Magento 2 offers a wide range of tools which covers all the needs of the retailer including the advanced digital marketing tools.
Mainly, in the latest release of Magento 2.4 it became the best chance to progress with all the backwards-incompatible changes that were waiting for years. After the speech of LBajsarowicz spoken at the recent Magento Conferences decided to replace inheritance with composition. The major change was the Pull Request and its followup which was introduced by Vinai Kopp.
There is a major architectural change done in decomposition of controllers by Lena Orobei and vinai Kopp. Both have started delivering by continuous support of each other and a great encouragement of LBajsarowicz.
To implement new Controller Action
\Magento\Framework\App\ActionInterface
Benefits
No need to extend
For creating a fully functional action controller now there is no need of extending from class.
Example controller GET Action
use Magento\Framework\App\Action\HttpGetActionInterface; use Magento\Framework\View\Result\PageFactory; class MyController implements HttpGetActionInterface { /** @var PageFactory */ protected $resultPageFactory; public function __construct(PageFactory $resultPageFactory) { $this->resultPageFactory = $resultPageFactory; } public function execute() { return $this->resultPageFactory->create(); } }
Everyone shall have noticed that here they have used \Magento\Framework\App\Action\HttpGetActionInterface. It is a method-specific Interface extending ActionInterface. If you want to explicitly define what methods are going to be handled by the Controller, the most common interfaces are:
\Magento\Framework\App\Action\HttpDeleteActionInterface
\Magento\Framework\App\Action\HttpGetActionInterface
\Magento\Framework\App\Action\HttpPostActionInterface
\Magento\Framework\App\Action\HttpPutActionInterface
Please be aware that the HEAD method is handled the same way that GET is.
Note: Changes to Magento core are fully backwards-compatible, so you still have time to migrate from Inheritance to Composition.
Hence, by going through the above article you may get all the rich and valuable information regarding the Decomposition of Magento Controllers provided by Magento 2.
Happy Reading?
Hello Magento Friends, In today’s blog, I will explain How to Add Tooltip in Checkout…
MongoDB is a popular NoSQL database that offers flexibility and scalability when handling modern web…
In NodeJS, callbacks empower developers to execute asynchronous operations like reading files, handling requests, and…
Hello Magento Friends, In today’s blog, we will learn How to Show SKU in Order…
The "Buy Now" and "Add to Cart" buttons serve as the primary call-to-action (CTA) elements…
Hello Magento Friends, In Magento 2, the checkout process allows customers to choose multiple shipping…
View Comments
Why you call it decomposition,
isn't de means removing composition,
while you adding it ?