Problem/Motivation

We need custom access handling within ECA. Therefore we should provide events and actions that enable fine-granular control of entity and field access.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork eca-3282649

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mxh created an issue. See original summary.

mxh’s picture

Priority: Normal » Major

It's not part of the critical list of issues that need to be fixed before stable 1.0, but turns out entity and field access is a crucial thing for our process requirements. Will try to address it soon, but can also move into 1.1.x if I don't get to this beforehand.

jurgenhaas’s picture

Issue tags: -release1.0
Parent issue: #3238206: ECA 1.0.0 stable release plan »

Removing it from the 1.0 roadmap as proposed above. But leaving it as major.

mxh’s picture

Title: eca_content: Provide events and actions to determine entity access and field access » eca_access: Provide events and actions to determine entity access and field access

Makes probably more sense to put into its own sub-module, as it can address content and config entities at the same time.

mxh’s picture

Assigned: Unassigned » mxh

mxh’s picture

Assigned: mxh » Unassigned
Status: Active » Needs review
mxh’s picture

I've renamed ContentEntityEventInterface into EntityEventInterface, as this one is actually not bound to content entities.

jurgenhaas’s picture

Status: Needs review » Reviewed & tested by the community

Very interesting implementation! In a positive sense of course. I was confused at first but then started to understand what this actually does. Like it.

While reviewing the code, I found a couple of typos and code style warnings. Committed the fixes right to the MR, hope that's ok.

Set this to RTBC, only wonder about the 48 line code block in \Drupal\eca_access\Plugin\ECA\Event\AccessEvent::lazyLoadingWildcard which is a duplication of what we already have in \Drupal\eca_form\Plugin\ECA\Event\FormEvent. Is it worth to optimize that? If not, we can still do that later of course.

mxh’s picture

All good, thanks for fixing the typos.

Except I'm wondering why you removed the sentence from the AccessResult::allowed() call. I'd like to keep the sentence in there, i.e.

$result = AccessResult::allowed("Allowed by configured ECA");

as this helps for debugging access results.

Set this to RTBC, only wonder about the 48 line code block in \Drupal\eca_access\Plugin\ECA\Event\AccessEvent::lazyLoadingWildcard which is a duplication of what we already have in \Drupal\eca_form\Plugin\ECA\Event\FormEvent. Is it worth to optimize that? If not, we can still do that later of course.

While the code block is rather large and very similar to the one of the form event, both events are not related to each other. I think it's not yet worth it to take care about an optimization at this place.

jurgenhaas’s picture

Except I'm wondering why you removed the sentence from the AccessResult::allowed() call.

Because the PHPCS complained about it as this method does not take any arguments. The sentence should then be a comment, otherwise this could create strange results later on if the method declaration ever changed unnoticed.

While the code block is rather large and very similar to the one of the form event, both events are not related to each other. I think it's not yet worth it to take care about an optimization at this place.

Well, it's 48 (!!!) identical lines that were found by the IDE - I wouldn't be able to spot such a thing ;-) But I'm ok with optimizing that later.

PHP 7.4 & MySQL 5.7, D9.3.0 164 pass, 1 fail

This is so "funny": the cron event fixes from earlier today haven't been part of this MR yet and hence DrupalCI struggled with timezones again. I merged the latest changes from 1.0.x-dev, so all tests should then pass again.

jurgenhaas’s picture

Oh wow, there has been another place where the timezone kicked in: \Drupal\Tests\eca_base\Unit\CronEventTest::appliesData used the date function to calculate the weekday but that function does not have any control over timezone and hence responded with Tuesday already, where it is still Monday. I've fixed that by calculating the weekday with the DateTime class like we do elsewhere as well.

  • jurgenhaas committed e1f42d1 on 1.0.x authored by mxh
    Issue #3282649 by mxh, jurgenhaas: eca_access: Provide events and...
jurgenhaas’s picture

Status: Reviewed & tested by the community » Fixed

Merged this now as the only outstanding question was about that code comment. If that still needs to be addressed, let's do so anyways.

mxh’s picture

Because the PHPCS complained about it as this method does not take any arguments. The sentence should then be a comment, otherwise this could create strange results later on if the method declaration ever changed unnoticed.

Aaah, that's why. The AccessResult class is a bit confusing IMO, although it's supposed to be one of the best designed classes in Drupal core 😄 thanks for fixing.

Status: Fixed » Closed (fixed)

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