5

We have below methods. It generally used for User Role wise Module Permission, as per set.

In Controller: _isAllowed

In Block: _isAllowedAction

At which stage & when this method is called & what's difference between both Method?

6

_isAllowed for controllers is called when the controller action is dispatched. to see if the current user has access to that specific action. If not, a 403 page is displayed.

_isAllowedAction has no specific general meaning. It is declared in just 4 blocks and it is used just in that class. It is not used in parent classes or in abstract block classes.

  • Magento\Cms\Block\Adminhtml\Page
  • Magento\Sales\Block\Adminhtml\Order\View
  • Magento\Sales\Block\Adminhtml\Order\Creditmemo\View
  • Magento\Sales\Block\Adminhtml\Order\Invoice\View

It does a similar thing as the _isAllowed method, it checks if the current user has access to certain actions, but it is used for displaying or not displaying certain buttons or links in the block.
For example in the admin page block it checks if the current user has access to save cms pages. If the user does not have access, then it removes the Add button. if he does have access it just updates the button label.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.