Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / paragraphs / src / ParagraphsBehaviorManager.php
1 <?php
2
3 namespace Drupal\paragraphs;
4
5 use Drupal\Core\Cache\CacheBackendInterface;
6 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Plugin\DefaultPluginManager;
8
9 /**
10  * Plugin type manager for paragraphs type behavior plugins.
11  *
12  * @ingroup paragraphs_behavior
13  */
14 class ParagraphsBehaviorManager extends DefaultPluginManager {
15
16   /**
17    * Constructs a ParagraphsBehaviorManager object.
18    *
19    * @param \Traversable $namespaces
20    *   An object that implements \Traversable which contains the root paths
21    *   keyed by the corresponding namespace to look for plugin implementations.
22    * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
23    *   Cache backend instance to use.
24    * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
25    *   The module handler.
26    */
27   public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
28     parent::__construct('Plugin/paragraphs/Behavior', $namespaces, $module_handler, 'Drupal\paragraphs\ParagraphsBehaviorInterface', 'Drupal\paragraphs\Annotation\ParagraphsBehavior');
29     $this->setCacheBackend($cache_backend, 'paragraphs_behavior_plugins');
30     $this->alterInfo('paragraphs_behavior_info');
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   public function getDefinitions() {
37     $definitions =  parent::getDefinitions();
38     uasort($definitions, 'Drupal\Component\Utility\SortArray::sortByWeightElement');
39     return $definitions;
40   }
41
42   /**
43    * Gets the applicable behavior plugins.
44    *
45    * Loop over the plugin definitions, check the applicability of each one of
46    * them and return the array of the applicable plugins.
47    *
48    * @return array
49    *   The applicable behavior plugins.
50    */
51   public function getApplicableDefinitions($paragraphs_type) {
52     $definitions = $this->getDefinitions();
53     $applicable_plugins = [];
54     foreach ($definitions as $key => $definition) {
55       if ($definition['class']::isApplicable($paragraphs_type)) {
56         $applicable_plugins[$key] = $definition;
57       }
58     }
59     return $applicable_plugins;
60   }
61
62 }