Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PluginList.php
Go to the documentation of this file.
1 <?php
8 
11 
15 class PluginList extends Interception\PluginList\PluginList
16 {
20  const PLUGIN_TYPE_BEFORE = 'before';
21  const PLUGIN_TYPE_AROUND = 'around';
22  const PLUGIN_TYPE_AFTER = 'after';
26  private $pluginList = [
27  self::PLUGIN_TYPE_BEFORE => [],
28  self::PLUGIN_TYPE_AROUND => [],
29  self::PLUGIN_TYPE_AFTER => []
30  ];
31 
36  private $pluginTypeMapping = [
40  ];
41 
47  public function getPluginsConfig()
48  {
49  $this->_loadScopedData();
50 
51  return $this->_inherited;
52  }
53 
61  public function setScopePriorityScheme($areaCodes)
62  {
63  $this->_scopePriorityScheme = $areaCodes;
64  }
65 
74  protected function isCurrentScope($scopeCode)
75  {
76  return false;
77  }
78 
85  private function getPlugins($type)
86  {
87  $this->_loadScopedData();
88  if (!isset($this->_inherited[$type]) && !array_key_exists($type, $this->_inherited)) {
89  $this->_inheritPlugins($type);
90  }
91  return $this->_inherited[$type];
92  }
93 
102  {
103  $this->getPlugins($className);
104  if (!isset($this->_inherited[$className])) {
105  return $this->pluginList;
106  }
107 
108  foreach ($this->_inherited[$className] as $plugin) {
109  foreach ($this->_definitions->getMethodList($plugin['instance']) as $pluginMethod => $methodTypes) {
110  $this->addPluginToList(
111  $plugin['instance'],
112  $pluginMethod,
113  $methodTypes,
115  );
116  $this->addPluginToList(
117  $plugin['instance'],
118  $pluginMethod,
119  $methodTypes,
121  );
122  $this->addPluginToList(
123  $plugin['instance'],
124  $pluginMethod,
125  $methodTypes,
127  );
128  }
129  }
130  return $this->pluginList;
131  }
132 
142  private function addPluginToList($pluginInstance, $pluginMethod, $methodTypes, $typeCode)
143  {
144  if ($methodTypes & $typeCode) {
145  if (!array_key_exists($pluginInstance, $this->pluginList[$this->pluginTypeMapping[$typeCode]])) {
146  $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance] = [];
147  }
148 
149  if (!in_array($pluginMethod, $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance])) {
150  $this->pluginList[$this->pluginTypeMapping[$typeCode]][$pluginInstance][] = $pluginMethod;
151  }
152  }
153  }
154 }
$type
Definition: item.phtml:13
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31