Feature request from erikhansen, posted on GitHub Jul 13, 2015
I've been working with Magento 2 for the past couple of months. There have several times where I've tried to find what constant to use for the backend area and have been distracted by an inappropriate constant.
The lib/internal/Magento/Framework/App/Area.php
file contains these constants:
class Area implements \Magento\Framework\App\AreaInterface
{
const AREA_GLOBAL = 'global';
const AREA_FRONTEND = 'frontend';
const AREA_ADMIN = 'admin';
If a developer is casually browsing the code, they may think that \Magento\Framework\App\Area::AREA_ADMIN
is the appropriate constant to use to refer to the backend/adminhtml area.
However this is another constant in a different class that is the appropriate constant to use when referring to the backend area: \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE
(the value of this constant is adminhtml
)
To avoid this confusion for developers, I would recommend moving the backend constant into the \Magento\Framework\App\Area
class and then add clear comments describing how the AREA_ADMIN
constant differs from the AREA_ADMINHTML
(or AREA_BACKEND
, depending on what you decide to call it) constant.