Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Here is some feedback from https://www.drupal.org/node/2694755#comment-11009515
FlagAccessController isn't really a controller, just has two access methods that are re-used. This would be better as a registered access check. See NodeAddAccessCheck for example and how it is registered in node.services.yml. You could register it as _flag_access, with the value flag/unflag. That's a lot easier to use in the various routes.
That sounds like a really good idea.
I am just spinning off a new issue to deal with that.
Comment | File | Size | Author |
---|---|---|---|
#12 | interdiff-2695983-3-12.txt | 3.09 KB | martin107 |
#12 | accessCheck-2695983-12.patch | 6.39 KB | martin107 |
| |||
#3 | accessCheck-2695983-3.patch | 5.99 KB | martin107 |
Comments
Comment #2
joachim CreditAttribution: joachim commentedYup, this sounds good.
Comment #3
martin107 CreditAttribution: martin107 commentedThis removes one class from \Drupal\flag namespace - which is a good thing.
I have tested it manually and can confirm a simple flag can be flagged and unflagged. I expect testbot may still find problems.
Regarding phpcs, both new classes are clean.
As a small note
We are copying from NodeAddAccessCheck which implements \Drupal\Core\Routing\Access\AccessInterface
AccessInterface is an empty Interface which this #2266817: Deprecate empty AccessInterface and remove usages proposes to mark it
For the moment we must also extend it.. but down the road there will be a small maintenance issue.
Comment #5
socketwench CreditAttribution: socketwench at FFW commentedHuh. It passes locally, even on the latest dev, but testbot doesn't like it.
Comment #6
Berdirwhy no have a single check with flag/unflag as value instead of that super-weird quoted TRUE. We need a value anyway, and that seems easier to me.
You can access the value with $route->getRequirement(), see \Drupal\node\Access\NodeRevisionAccessCheck::access for an example.
Comment #7
socketwench CreditAttribution: socketwench at FFW commented@berdir They are treated as separate operations, so it kinda makes sense to have a separate flag and unflag access check. It doesn't make it look less weird in the routing.yml though...
Comment #8
Berdir"_entity_access: node.delete" and "_entity_access: node.update" are separate operations too, seems conceptually quite similar to me?
Comment #9
socketwench CreditAttribution: socketwench at FFW commentedExtra backslash.
Comment #10
martin107 CreditAttribution: martin107 commentedGoing back to the original - I think I missed at step.
and looking at the uses of _node_add_access
I think _flag_access should be changed
- _flag_access: 'TRUE'
+ _flag_access: 'entity:flag{flag}' or something - it is so badly documented that I am having trouble figuring it out.
[ yes having the string 'TRUE' in a yml file is a commonly used drupal madness that yml's creators tried so hard to avoid. ]
Comment #11
martin107 CreditAttribution: martin107 commented@socketwench regarding #5
I can repeat the failures -
for reference here is my setup
php7.0
drupal 8.2.x
opcode cache: on
nginx/1.8.0
mysql 5.5.42
Comment #12
martin107 CreditAttribution: martin107 commentedLinkTypeFiedEntryTest now passes ... I suspect the other tests will also now work.
Regarding Berdir concerns about having a single check for both flag and unflag.
I would rather create 2 similar class with all the associated maintenance issues that creates for the sake of a clean linear flow through through methods without if statements.
I appreciated not every likes this style ...for the moment I am going to leave this issue as a straight conversion project.
Comment #13
martin107 CreditAttribution: martin107 commentedComment #14
socketwench CreditAttribution: socketwench at FFW commentedI much prefer this approach, even if it comes at the cost of an additional class. Thank you!
Comment #15
joachim CreditAttribution: joachim commented> "_entity_access: node.delete" and "_entity_access: node.update" are separate operations too, seems conceptually quite similar to me?
Shouldn't have left it so long to say something... I was thinking I agree with Berdir's comment above.
But the patch is ready and we have one maintainer who likes it, so that's fair enough.
Comment #16
socketwench CreditAttribution: socketwench at FFW commentedI'd rather treat flag/unflag as separate operations conceptually when designing APIs, since it leaves open the (unlikely) possibility of other operations.
Comment #18
socketwench CreditAttribution: socketwench at FFW commentedComment #19
socketwench CreditAttribution: socketwench at FFW commentedThanks everyone! If there's any further changes, let's split those off into other issues. I want to unblock #2694755: Top level Flag namespace is too crowded