Problem/Motivation

FlagInterface specifies a method named hasActionAccess() which takes two parameters: A string containing the action to perform, and an optional AccountInterface. This method can only accept actions "flag" and "unflag". hasActionAccess() is called in flag_entity_view() and FlagService.

Proposed resolution

Instead of accepting a string parameter, we remove the generalized action method and replace it with two methods: canFlag() and canUnflag().

Remaining tasks

Write patch.

User interface changes

None.

API changes

FlagInterface::hasActionAccess() will be replaced with FlagInterface::canFlag() and FlagInterface::canUnflag().

Comments

joachim’s picture

I'm not entirely sure about this...

Core still has a pattern of having an $operation verb for access controls, eg in Node:

  /**
   * {@inheritdoc}
   */
  public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE) {

Of course here Flag is a config entity, not a content entity. Is there anything comparable in core -- a config entity with access control?

socketwench’s picture

That is a very good point. It also occurred to me that if child classes wanted to add permissions the canFlag()/canUnflag() system would be limiting.

Either way, I wanted to split the discussion from the original issue.

socketwench’s picture

Status: Active » Closed (won't fix)