3 namespace Drupal\migrate\Plugin;
5 use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
6 use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
9 * Remove definitions which refer to a non-existing source plugin.
11 class NoSourcePluginDecorator implements DiscoveryInterface {
16 * The Discovery object being decorated.
18 * @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
23 * Constructs a NoSourcePluginDecorator object.
25 * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
26 * The object implementing DiscoveryInterface that is being decorated.
28 public function __construct(DiscoveryInterface $decorated) {
29 $this->decorated = $decorated;
35 public function getDefinitions() {
36 /** @var \Drupal\Component\Plugin\PluginManagerInterface $source_plugin_manager */
37 $source_plugin_manager = \Drupal::service('plugin.manager.migrate.source');
38 return array_filter($this->decorated->getDefinitions(), function (array $definition) use ($source_plugin_manager) {
39 return $source_plugin_manager->hasDefinition($definition['source']['plugin']);
44 * Passes through all unknown calls onto the decorated object.
46 * @param string $method
47 * The method to call on the decorated object.
52 * The return value from the method on the decorated object.
54 public function __call($method, array $args) {
55 return call_user_func_array([$this->decorated, $method], $args);