X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FConverter%2FFunctions%2FCToolsGetPlugins.php;fp=web%2Fmodules%2Fcontrib%2Fdrupalmoduleupgrader%2Fsrc%2FPlugin%2FDMU%2FConverter%2FFunctions%2FCToolsGetPlugins.php;h=baf51962da94e0e82d19fa4006fa73ee0bf61c1d;hp=0000000000000000000000000000000000000000;hb=8acec36f19c470dfcda1ae2336826a782f41874c;hpb=e0411c4e83ba0d079034db83c3f7f55be24a0e35 diff --git a/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/CToolsGetPlugins.php b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/CToolsGetPlugins.php new file mode 100644 index 000000000..baf51962d --- /dev/null +++ b/web/modules/contrib/drupalmoduleupgrader/src/Plugin/DMU/Converter/Functions/CToolsGetPlugins.php @@ -0,0 +1,66 @@ +getArguments(); + return ($arguments[0] instanceof StringNode && $arguments[0]->toValue() == $target->id() && $arguments[1] instanceof StringNode); + } + + /** + * {@inheritdoc} + */ + public function rewrite(FunctionCallNode $call, TargetInterface $target) { + if (! $this->canRewrite($call, $target)) { + return NULL; + } + + $arguments = $call->getArguments(); + $plugin_owner = $arguments[0]->toValue(); + $plugin_type = $arguments[1]->toValue(); + + $services = $target->getServices(); + $service_id = 'plugin.manager.' . $plugin_owner . '.' . $plugin_type; + $services->set($service_id, [ + 'class' => 'Drupal\Core\Plugin\DefaultPluginManager', + 'arguments' => [ + 'Plugin/' . $plugin_owner . '/' . $plugin_type, + '@container.namespaces', + '@module_handler', + 'Drupal\Component\Plugin\PluginBase', + 'Drupal\Component\Annotation\Plugin', + ], + ]); + $this->writeInfo($target, 'services', [ 'services' => $services->toArray() ]); + + return ClassMethodCallNode::create('\Drupal', 'service') + ->appendArgument($service_id) + ->appendMethodCall('getDefinitions'); + } + +}