Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / rest / src / Plugin / Type / ResourcePluginManager.php
1 <?php
2
3 namespace Drupal\rest\Plugin\Type;
4
5 use Drupal\Core\Cache\CacheBackendInterface;
6 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Plugin\DefaultPluginManager;
8
9 /**
10  * Manages discovery and instantiation of resource plugins.
11  *
12  * @see \Drupal\rest\Annotation\RestResource
13  * @see \Drupal\rest\Plugin\ResourceBase
14  * @see \Drupal\rest\Plugin\ResourceInterface
15  * @see plugin_api
16  */
17 class ResourcePluginManager extends DefaultPluginManager {
18
19   /**
20    * Constructs a new \Drupal\rest\Plugin\Type\ResourcePluginManager object.
21    *
22    * @param \Traversable $namespaces
23    *   An object that implements \Traversable which contains the root paths
24    *   keyed by the corresponding namespace to look for plugin implementations.
25    * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
26    *   Cache backend instance to use.
27    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
28    *   The module handler to invoke the alter hook with.
29    */
30   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
31     parent::__construct('Plugin/rest/resource', $namespaces, $module_handler, 'Drupal\rest\Plugin\ResourceInterface', 'Drupal\rest\Annotation\RestResource');
32
33     $this->setCacheBackend($cache_backend, 'rest_plugins');
34     $this->alterInfo('rest_resource');
35   }
36
37   /**
38    * {@inheritdoc}
39    *
40    * @deprecated in Drupal 8.2.0.
41    *   Use Drupal\rest\Plugin\Type\ResourcePluginManager::createInstance()
42    *   instead.
43    *
44    * @see https://www.drupal.org/node/2874934
45    */
46   public function getInstance(array $options){
47     if (isset($options['id'])) {
48       return $this->createInstance($options['id']);
49     }
50   }
51
52 }