-
Notifications
You must be signed in to change notification settings - Fork 173
z. [deprecated] OVERVIEW Defining your own RESTful resource plugin (2.x)
For a video tutorial covering the basics see "4. Writing the first resource" on Youtube.
From here down we assume you have viewed the above and understand the basics. Also, we'll assume you now have a new class file with the appropriate filename and location in your filesystem.
The resource definition introduces something that may be new to the Drupal 7 developer—the Drupal 8/Symfony-style "annotation". This is essentially a bunch of comments preceding the class, which are actually read by the plugin system (in this case the plug.module) in order to learn all about the class.
e.g.
/**
* Class Articles
* @package Drupal\restful\Plugin\resource
*
* @Resource(
* name = "articles:1.1",
* resource = "articles",
* label = "Articles",
* description = "Export the article content type.",
* authenticationOptional = TRUE,
* dataProvider = {
* "entityType": "node",
* "bundles": {
* "article"
* },
* },
* majorVersion = 1,
* minorVersion = 1
* )
*/
In general a good rule of thumb is that if you are inheriting from an old resource, you bump up the minor version. If you are not, then bump up the major version.
If you're extending a resource that RESTful provides out-of-the-box (e.g. users) but you haven't incremented your version number, RESTful may not see your resource, instead using the default one. e.g. if you're extending RESTful's users v1.0, be sure to call yours users v1.1 or higher.