class FeedsAnnotationFactory in Feeds 8.3
Plugin factory which uses the plugin definition to find arguments.
Hierarchy
- class \Drupal\Component\Plugin\Factory\DefaultFactory implements FactoryInterface
- class \Drupal\Core\Plugin\Factory\ContainerFactory
- class \Drupal\feeds\Plugin\Type\FeedsAnnotationFactory
- class \Drupal\Core\Plugin\Factory\ContainerFactory
Expanded class hierarchy of FeedsAnnotationFactory
Deprecated
in Feeds 8.x-3.0-alpha6, will be removed before Feeds 8.x-3.0.
File
- src/
Plugin/ Type/ FeedsAnnotationFactory.php, line 12
Namespace
Drupal\feeds\Plugin\TypeView source
class FeedsAnnotationFactory extends ContainerFactory {
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = []) {
$definition = $this->discovery
->getDefinition($plugin_id);
if (empty($definition['arguments'])) {
return parent::createInstance($plugin_id, $configuration);
}
@trigger_error('FeedsAnnotationFactory is deprecated in Feeds 8.x-3.0-alpha6 and will be removed before Feeds 8.x-3.0. Implement \\Drupal\\Core\\Plugin\\ContainerFactoryPluginInterface instead.', E_USER_DEPRECATED);
// Find arguments from the annotation.
$arguments = [
$configuration,
$plugin_id,
$definition,
];
foreach ($definition['arguments'] as $argument) {
if (substr($argument, 0, 1) === '@') {
$arguments[] = \Drupal::service(substr($argument, 1));
}
elseif (substr($argument, 0, 1) === '%' && substr($argument, -1) === '%') {
$arguments[] = \Drupal::getContainer()
->getParameter(substr($argument, 1, -1));
}
else {
$arguments[] = $argument;
}
}
$ref_class = new \ReflectionClass(static::getPluginClass($plugin_id, $definition, $this->interface));
return $ref_class
->newInstanceArgs($arguments);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultFactory:: |
protected | property | The object that retrieves the definitions of the plugins that this factory instantiates. | |
DefaultFactory:: |
protected | property | Defines an interface each plugin should implement. | |
DefaultFactory:: |
public static | function | Finds the class relevant for a given plugin. | 1 |
DefaultFactory:: |
public | function | Constructs a Drupal\Component\Plugin\Factory\DefaultFactory object. | |
FeedsAnnotationFactory:: |
public | function |
Creates a pre-configured instance of a plugin. Overrides ContainerFactory:: |