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.
Problem/Motivation
As reported by @bertramakers in #1964034-13: Pass entity_type into Serializer via context we missed some properties for the Drupal\rest\Annotation\RestResource
class.
Proposed resolution
Add current properties as available through
$resource->getPluginDefinition()
in \Drupal\rest\RequestHandler::handle
Remaining tasks
User interface changes
API changes
Comment | File | Size | Author |
---|---|---|---|
#18 | 2359245-18.patch | 1.28 KB | Wim Leers |
#1 | Screen Shot 2015-01-07 at 15.54.57.png | 295.22 KB | marthinal |
plugin-definition.png | 33.33 KB | clemens.tolboom |
Comments
Comment #1
marthinal CreditAttribution: marthinal commentedI'm working to create a Rest Resource where anonymous users can register user accounts.
For this resource there's no canonical path and when using Restui module the path is empty.So, can we add for example a "path" to "uri_paths" ?
Attached image with the expected result.
Comment #2
Wim Leers#1839346: REST module: POST/create and #2019123: Use the same canonical URI paths as for HTML routes should have updated the annotation class, but they did not.
Comment #3
Wim LeersIn fact, the
deriver
(originallyderivative
) goes back to when this module was first created (#1816354: Add a REST module, starting with DELETE). When the concept of plugin type-specific annotations was added, it was simply forgotten in #2195571: Add a dedicated @RestResource annotation class.It looks like annotations are not strict enough…
Comment #4
Wim LeersIn fact:
deriver
is something supported by\Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator
, it does not belong in the annotation definition apparently. (Messy, but apparently that's the way it is intended.)id
andentity_type
.Moving to
to gather feedback.Comment #5
Wim LeersThis part is actually used by
\Drupal\rest\RequestHandler::handle()
, so at least this seems to belong on the annotation.Comment #9
Wim LeersCompletely new patch, #5 didn't apply anymore.
Comment #10
Wim LeersComment #11
dawehnerShould this default to an empty array?
Comment #12
Wim LeersThat's probably better, yes.
Do we want this?
No other plugin annotation has this… (as I already pointed out in #4.1).
Comment #13
dawehnerSeems unneeded then. We should that better add to the base class, IMHO.
Comment #14
Wim LeersDone.
Comment #15
dawehnerNow the documentation ideally should make clear that there are plugin types which don't support deriver
Comment #16
Wim Leers"if any"
string|null
Isn't this sufficiently clear?
Comment #17
dawehnerWell, the question is, do we want to distinct between the case: Someone hasn't defined a deriver class in their annotation vs. the plugin type don't support them.
Comment #18
Wim LeersOkay, how about this: we don't deal with
deriver
at all here, it's out of scope for the REST module anyway :)Comment #19
dawehnerI 100% agree with that
Comment #21
Wim LeersRandom fail in
Drupal\Tests\inline_form_errors\FunctionalJavascript\FormErrorHandlerCKEditorTest
.Comment #23
Wim LeersRandom CI infra fail.
Comment #26
Gábor HojtsyThe "new" uri_paths key was a bit puzzling to me but I see it is already being used on these resources:
So we are indeed just documenting what we already have. Thanks all!
Comment #27
Wim LeersIndeed :)
Comment #28
Wim LeersThis tag is probably also relevant.