Magento 2 – Consequences of Not Naming a Plugin Class ‘\Plugin’

magento2plugin

Are there any consequences for using a plugin class in Magento 2 that doesn't end in \Plugin? The docs suggest that this class should end in the name \Plugin.

The name of a plug-in’s class or its virtual type. Use the following schema when you specify this element: \Plugin.

However, there's several code plugins that don't follow this.

<!-- #File: app/code/Magento/Weee/etc/frontend/di.xml-->
<plugin name="weee-app-action-dispatchController-context-plugin"
        type="Magento\Weee\Model\App\Action\ContextPlugin"/>

Are there any programmatic consequences to not using \Plugin in your class name? Or is this just a convention — similar to Magento 1's _Observer class name convention?

Best Answer

So the official training slides/instruction say "The name of a plugin class or its virtual type; uses the naming convention \Plugin.". However, the solutions guide for the exercises creates a plugin without following that convention. So unless something has changed architecturally, I would say this is just a convention

Related Topic