summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2014-02-28 10:47:37 (GMT)
committerNathaniel Catchpole2014-02-28 10:47:37 (GMT)
commitd077f162378393614cb838f34a584aa15b90c52a (patch)
tree4874a8e89a7a23e4aecc27e03a4dc0dad74fcf2d
parent78b48c89ada71ae10857f8cb7aa12c25c9914560 (diff)
Issue #2195571 by Les Lim: Add a dedicated @RestResource annotation class.
-rw-r--r--core/modules/rest/lib/Drupal/rest/Annotation/RestResource.php35
-rw-r--r--core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php9
-rw-r--r--core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php2
-rw-r--r--core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php2
4 files changed, 41 insertions, 7 deletions
diff --git a/core/modules/rest/lib/Drupal/rest/Annotation/RestResource.php b/core/modules/rest/lib/Drupal/rest/Annotation/RestResource.php
new file mode 100644
index 0000000..c9ac9e9
--- /dev/null
+++ b/core/modules/rest/lib/Drupal/rest/Annotation/RestResource.php
@@ -0,0 +1,35 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\rest\Annotation\RestResource.
+ */
+
+namespace Drupal\rest\Annotation;
+
+use \Drupal\Component\Annotation\Plugin;
+
+/**
+ * Defines a REST resource annotation object.
+ *
+ * @Annotation
+ */
+class RestResource extends Plugin {
+
+ /**
+ * The resource plugin ID.
+ *
+ * @var string
+ */
+ public $id;
+
+ /**
+ * The human-readable name of the resource plugin.
+ *
+ * @ingroup plugin_translatable
+ *
+ * @var \Drupal\Core\Annotation\Translation
+ */
+ public $label;
+
+}
diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php
index 0ad6b0f..6ff5a34 100644
--- a/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/Type/ResourcePluginManager.php
@@ -9,9 +9,8 @@ namespace Drupal\rest\Plugin\Type;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
-use Drupal\Core\Language\LanguageManager;
+use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
-use Drupal\Core\Plugin\Discovery\CacheDecorator;
/**
* Manages discovery and instantiation of resource plugins.
@@ -26,13 +25,13 @@ class ResourcePluginManager extends DefaultPluginManager {
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
- * @param \Drupal\Core\Language\LanguageManager $language_manager
+ * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
- public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) {
- parent::__construct('Plugin/rest/resource', $namespaces);
+ public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) {
+ parent::__construct('Plugin/rest/resource', $namespaces, 'Drupal\rest\Annotation\RestResource');
$this->setCacheBackend($cache_backend, $language_manager, 'rest_plugins');
$this->alterInfo($module_handler, 'rest_resource');
diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php
index bd05a5a..57aaf81 100644
--- a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/DBLogResource.php
@@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Provides a resource for database watchdog log entries.
*
- * @Plugin(
+ * @RestResource(
* id = "dblog",
* label = @Translation("Watchdog database log")
* )
diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php
index 53281e1..6cbb282 100644
--- a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php
+++ b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php
@@ -19,7 +19,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Represents entities as resources.
*
- * @Plugin(
+ * @RestResource(
* id = "entity",
* label = @Translation("Entity"),
* serialization_class = "Drupal\Core\Entity\Entity",