cancel
Showing results for 
Search instead for 
Did you mean: 

Magento\Backend\App\AbstractAction::_isAllowed() should use a static binding

0 Kudos

Magento\Backend\App\AbstractAction::_isAllowed() should use a static binding

Feature request from brideo, posted on GitHub Nov 13, 2015

http://php.net/manual/en/language.oop5.late-static-bindings.php

Rather than this:

/**
 * @return bool
 */
protected function _isAllowed()
{
    return $this->_authorization->isAllowed(self::ADMIN_RESOURCE);
}

We should have this:

/**
 * @return bool
 */
protected function _isAllowed()
{
    return $this->_authorization->isAllowed(static::ADMIN_RESOURCE);
}

By using a static binding, we don't have to completely re-write the _isAllowed method in our controller action, instead we can simply define our ADMIN_RESOURCE constant, we then can let the AbstractAction handle our logic.

This would be a completely backwards compatible change.

6 Comments
apiuser
New Member

Comment from ashsmith, posted on GitHub Nov 13, 2015

:+1:

apiuser
New Member

Comment from pantaoran, posted on GitHub Jan 15, 2016

I also just stumbled across this. Please implement this.

apiuser
New Member

Comment from karthickannan, posted on GitHub Jan 20, 2016

apiuser
New Member

Comment from antonkril, posted on GitHub Jan 20, 2016

We have plans to move Action Resource configuration to XML files.

But agree that static might be a good quick improvement

apiuser
New Member

Comment from brideo, posted on GitHub Jan 20, 2016

I'm happy to submit a pull request if this gets approved.

apiuser
New Member

Comment from brideo, posted on GitHub Feb 16, 2016

I see the static binding has been added but the controllers weren't updated, I have done so in the following pull request:

https://github.com/magento/magento2/pull/3428