Further modules included.
[yaffs-website] / web / modules / contrib / filefield_sources / src / FilefieldSourceManager.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\filefield_sources\FilefieldSourceManager.
6  */
7
8 namespace Drupal\filefield_sources;
9
10 use Drupal\Core\Cache\CacheBackendInterface;
11 use Drupal\Core\Extension\ModuleHandlerInterface;
12 use Drupal\Core\Plugin\DefaultPluginManager;
13
14 /**
15  * Provides a plugin manager for file field source.
16  *
17  * @see \Drupal\filefield_sources\Annotation\FilefieldSource
18  * @see \Drupal\filefield_sources\FilefieldSourceInterface
19  * @see plugin_api
20  */
21 class FilefieldSourceManager extends DefaultPluginManager {
22
23   /**
24    * Constructs a FilefieldSourceManager object.
25    *
26    * @param \Traversable $namespaces
27    *   An object that implements \Traversable which contains the root paths
28    *   keyed by the corresponding namespace to look for plugin implementations.
29    * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
30    *   Cache backend instance to use.
31    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
32    *   The module handler to invoke the alter hook with.
33    */
34   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
35     $this->setCacheBackend($cache_backend, 'filefield_sources');
36
37     parent::__construct('Plugin/FilefieldSource', $namespaces, $module_handler, 'Drupal\filefield_sources\FilefieldSourceInterface', 'Drupal\filefield_sources\Annotation\FilefieldSource');
38   }
39
40   /**
41    * {@inheritdoc}
42    */
43   public function getDefinitions() {
44     $definitions = parent::getDefinitions();
45     if (!\Drupal::moduleHandler()->moduleExists('imce')) {
46       unset($definitions['imce']);
47     }
48     if (!filefield_sources_curl_enabled()) {
49       unset($definitions['remote']);
50     }
51     return $definitions;
52   }
53
54 }