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.
For different usecases it is helpful to have an implementation of entity access for create.
Comment | File | Size | Author |
---|---|---|---|
#23 | entity-access-2028585-23.patch | 1.33 KB | tim.plunkett |
#20 | access-2028585-20.patch | 8.24 KB | ParisLiakos |
#20 | interdiff.txt | 632 bytes | ParisLiakos |
#18 | access-2028585-18.patch | 8.1 KB | ParisLiakos |
#18 | interdiff.txt | 1.87 KB | ParisLiakos |
Comments
Comment #1
dawehnerComment #2
tim.plunkettI was hoping to use this for #1987860: Convert taxonomy_term_add() to a new style controller, but it seems like the bundle value must be hardcoded?
I can't see when that's actually useful.
There are only two usages of entity_page_create_access() in core,
Either it doesn't pass a bundle:
entity_page_create_access('taxonomy_vocabulary')
(via access callback/access arguments for admin/structure/taxonomy/add)Or pass a dynamic value:
(for admin/structure/taxonomy/manage/%taxonomy_vocabulary/add)
Obviously we should refactor other parts of core to use the more generic approach when possible, but I'm not sure we'll ever get this working for bundles.
Comment #3
tim.plunkettWhat about adding a protected method to this for subclasses to easily define what goes in their values?
Then you can register your own subclass of this and override like so:
Comment #4
tim.plunkettIf we don't choose to do what I suggest in #3, let's just roll what #1 does directly into EntityCheckAccess when $operation == 'create'.
Comment #5
dawehnerIt seems to be that moving the functionality into the method makes actually quite amount of sense.
Comment #7
tim.plunkettI considered doing that. That's probably okay, you can just not call parent:: if you don't care.
That's a random fail, going to retest.
Comment #8
tim.plunkett#5: access-2028585-5.patch queued for re-testing.
Comment #9
pfrenssenThis is also useful for #1987866: Convert taxonomy_vocabulary_add() to a new style controller.
Comment #10
ParisLiakos CreditAttribution: ParisLiakos commentedlooks good..we might not have any usages of it, but we have tests, and they are pretty solid. rtbc?
Comment #11
tim.plunkettRTBC +1, we can immediately use this in both taxonomy conversions.
Comment #12
ParisLiakos CreditAttribution: ParisLiakos commentedsmall missing docblock!
Comment #15
ParisLiakos CreditAttribution: ParisLiakos commented#12: access-2028585-12.patch queued for re-testing.
Comment #16
twistor CreditAttribution: twistor commentedThis could be simplified quite a bit.
list($entity_type, $bundle) = explode(':', $route->getRequirement('_entity_create_access') . ':')
This comment is out of place.
Why is the request being passed in here?
$bundle should default to NULL.
The return docs are incorrect.
Leaving as NR to see test results.
Comment #17
tim.plunkettThe Request is needed to do anything useful in a subclass. See #3.
The rest is valid.
Comment #18
ParisLiakos CreditAttribution: ParisLiakos commentedthis should take care of points above
Comment #19
dawehnerMissing docs
Comment #20
ParisLiakos CreditAttribution: ParisLiakos commenteddocs added
Comment #21
dawehnerThanks
Comment #22
alexpottCommitted 0af43e4 and pushed to 8.x. Thanks!
Comment #23
tim.plunkettI feel stupid. This isn't good enough. We need this to do anything sufficiently complex.
See #1987860-10: Convert taxonomy_term_add() to a new style controller for an example.
Comment #24
ParisLiakos CreditAttribution: ParisLiakos commentedi had to check the other issue to figure out why this is needed, as well:/
Comment #25
alexpottCommitted 0453593 and pushed to 8.x. Thanks!