class NoSourcePluginDecorator

Same name in other branches
  1. 9 core/modules/migrate/src/Plugin/NoSourcePluginDecorator.php \Drupal\migrate\Plugin\NoSourcePluginDecorator
  2. 8.9.x core/modules/migrate/src/Plugin/NoSourcePluginDecorator.php \Drupal\migrate\Plugin\NoSourcePluginDecorator
  3. 11.x core/modules/migrate/src/Plugin/NoSourcePluginDecorator.php \Drupal\migrate\Plugin\NoSourcePluginDecorator

Remove definitions which refer to a non-existing source plugin.

Hierarchy

Expanded class hierarchy of NoSourcePluginDecorator

File

core/modules/migrate/src/Plugin/NoSourcePluginDecorator.php, line 11

Namespace

Drupal\migrate\Plugin
View source
class NoSourcePluginDecorator implements DiscoveryInterface {
    use DiscoveryTrait;
    
    /**
     * The Discovery object being decorated.
     *
     * @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
     */
    protected $decorated;
    
    /**
     * Constructs a NoSourcePluginDecorator object.
     *
     * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
     *   The object implementing DiscoveryInterface that is being decorated.
     */
    public function __construct(DiscoveryInterface $decorated) {
        $this->decorated = $decorated;
    }
    
    /**
     * {@inheritdoc}
     */
    public function getDefinitions() {
        
        /** @var \Drupal\Component\Plugin\PluginManagerInterface $source_plugin_manager */
        $source_plugin_manager = \Drupal::service('plugin.manager.migrate.source');
        return array_filter($this->decorated
            ->getDefinitions(), function (array $definition) use ($source_plugin_manager) {
            return $source_plugin_manager->hasDefinition($definition['source']['plugin']);
        });
    }
    
    /**
     * Passes through all unknown calls onto the decorated object.
     *
     * @param string $method
     *   The method to call on the decorated object.
     * @param array $args
     *   Call arguments.
     *
     * @return mixed
     *   The return value from the method on the decorated object.
     */
    public function __call($method, array $args) {
        return call_user_func_array([
            $this->decorated,
            $method,
        ], $args);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DiscoveryTrait::doGetDefinition protected function Gets a specific plugin definition.
DiscoveryTrait::getDefinition public function 3
DiscoveryTrait::hasDefinition public function
NoSourcePluginDecorator::$decorated protected property The Discovery object being decorated.
NoSourcePluginDecorator::getDefinitions public function Gets the definition of all plugins for this type. Overrides DiscoveryTrait::getDefinitions
NoSourcePluginDecorator::__call public function Passes through all unknown calls onto the decorated object.
NoSourcePluginDecorator::__construct public function Constructs a NoSourcePluginDecorator object.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.