magento2: Inconsistent location for plugins

I have noticed in app/code/Magento/CatalogUrlRewrite the location where Plugins are kept is inconsistent between Blocks & Models.

So in the code below (from app/code/Magento/CatalogUrlRewrite/etc/adminhtml/di.xml) shows Plugins for Models stored in the Model directory, but then Blocks and Controller Plugins are kept in a Plugins directory within the root of the module.

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    ...
    <type name="Magento\UrlRewrite\Model\StorageInterface">
        <plugin name="storage_plugin" type="Magento\CatalogUrlRewrite\Model\Category\Plugin\Storage"/>
    </type>
    <type name="Magento\Catalog\Block\Adminhtml\Category\Tab\Attributes">
        <plugin name="category_form_url_key_plugin" type="Magento\CatalogUrlRewrite\Plugin\Catalog\Block\Adminhtml\Category\Tab\Attributes"/>
    </type>
    ...
    <type name="Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper">
        <plugin name="product_save_rewrites_history_plugin" type="Magento\CatalogUrlRewrite\Plugin\Catalog\Controller\Adminhtml\Product\Initialization\Helper"/>
    </type>
</config>

Is there a reason behind this? Was it intentional?

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 2
  • Comments: 22 (14 by maintainers)

Commits related to this issue

Most upvoted comments

This is an inconsistency in the core which needs to be addressed. The proper location per documentation is in <module>/Plugin/

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

source: http://devdocs.magento.com/guides/v2.0/extension-dev-guide/plugins.html#plugin-declare