Problem/Motivation

In order to contain logic across all block types, BlockBase implements the public methods and then delegates to a protected method.
This prevents nasty chains of parent:: calls.

#2278541: Refactor block visibility to use condition plugins moves visibility logic from the block entity down to the block plugin, and makes this even more necessary.

Proposed resolution

Add a blockAccess() method.

Remaining tasks

N/A

User interface changes

N/A

API changes

All blocks currently implementing access() should implement blockAccess() instead

Files: 
CommentFileSizeAuthor
#1 block-2283969-1.patch7.78 KBtim.plunkett
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,063 pass(es). View

Comments

tim.plunkett’s picture

Status: Active » Needs review
FileSize
7.78 KB
PASSED: [[SimpleTest]]: [PHP 5.4 MySQL] 72,063 pass(es). View
tim.plunkett’s picture

Issue tags: +Page Manager
blueminds’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

Berdir’s picture

Does this need a change record (update), I guess the current access would still work but will break eventually when access() does more?

chx’s picture

I do not see how this could introduce another sechole so good to go.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ok, had few moments where I was concerned about one-offing Block's access stuff here, but was pointed to https://api.drupal.org/api/drupal/core%21modules%21block%21src%21BlockPl... which shows we are already doing that for e.g. blockForm, blockValidate, etc. so this just brings that code inline.

Talked to Tim about the change notice, he's going to go through and update all of them, under penalty of a picture of a sad pit bull. ;)

Therefore, committed and pushed to 8.x. Thanks!

  • Commit 12317b7 on 8.x by webchick:
    Issue #2283969 by tim.plunkett: Add a protected BlockBase::blockAccess...
tim.plunkett’s picture

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dawehner’s picture

Note: If we do move block visibility into the base class you can basically never just implement the interface. Block visibility is kind of orthogonal to pure access and could be implemented somehow outside.