abstract class ImportProcessorPluginBase in Entity Share 8.3
Defines a base class from which other processors may extend.
Plugins extending this class need to define a plugin definition array through annotation. The definition includes the following keys:
- id: The unique, system-wide identifier of the processor.
- label: The human-readable name of the processor, translated.
- description: A human-readable description for the processor, translated.
- stages: The default weights for all stages for which the processor should run. Available stages are defined by the STAGE_* constants in ImportProcessorInterface. This is, by default, used for supportsStage(), so if you don't provide a value here, your processor might not work as expected even though it implements the corresponding method.
A complete plugin definition should be written as in this example:
@ImportProcessor(
id = "my_processor",
label = @Translation("My Processor"),
description = @Translation("Does … something."),
stages = {
"prepare_entity_data" = 0,
"is_entity_importable" = 0,
"prepare_importable_entity_data" = 0,
"process_entity" = 0,
"post_entity_save" = 0,
},
locked = false,
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\entity_share_client\ImportProcessor\ImportProcessorPluginBase implements ContainerFactoryPluginInterface, ImportProcessorInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ImportProcessorPluginBase
6 files declare their use of ImportProcessorPluginBase
- ChangedTime.php in modules/
entity_share_client/ src/ Plugin/ EntityShareClient/ Processor/ ChangedTime.php - DefaultDataProcessor.php in modules/
entity_share_client/ src/ Plugin/ EntityShareClient/ Processor/ DefaultDataProcessor.php - EntityReference.php in modules/
entity_share_client/ src/ Plugin/ EntityShareClient/ Processor/ EntityReference.php - PhysicalFile.php in modules/
entity_share_client/ src/ Plugin/ EntityShareClient/ Processor/ PhysicalFile.php - Revision.php in modules/
entity_share_client/ src/ Plugin/ EntityShareClient/ Processor/ Revision.php
File
- modules/
entity_share_client/ src/ ImportProcessor/ ImportProcessorPluginBase.php, line 47
Namespace
Drupal\entity_share_client\ImportProcessorView source
abstract class ImportProcessorPluginBase extends PluginBase implements ImportProcessorInterface, ContainerFactoryPluginInterface {
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
/**
* {@inheritdoc}
*/
public function label() {
$plugin_definition = $this
->getPluginDefinition();
$label = $plugin_definition['label'];
if ($label instanceof TranslatableMarkup) {
$label = $label
->render();
}
return $label;
}
/**
* {@inheritdoc}
*/
public function getDescription() {
$plugin_definition = $this
->getPluginDefinition();
$description = '';
if (isset($plugin_definition['description'])) {
$description = $plugin_definition['description'];
if ($description instanceof TranslatableMarkup) {
$description = $description
->render();
}
}
return $description;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return $this->configuration;
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
/**
* {@inheritdoc}
*/
public function supportsStage($stage) {
$plugin_definition = $this
->getPluginDefinition();
return isset($plugin_definition['stages'][$stage]);
}
/**
* {@inheritdoc}
*/
public function getWeight($stage) {
if (isset($this->configuration['weights'][$stage])) {
return $this->configuration['weights'][$stage];
}
$plugin_definition = $this
->getPluginDefinition();
if (isset($plugin_definition['stages'][$stage])) {
return (int) $plugin_definition['stages'][$stage];
}
return 0;
}
/**
* {@inheritdoc}
*/
public function setWeight($stage, $weight) {
$this->configuration['weights'][$stage] = $weight;
return $this;
}
/**
* {@inheritdoc}
*/
public function isLocked() {
return !empty($this->pluginDefinition['locked']);
}
/**
* Form validation handler.
*
* @param array $form
* An associative array containing the structure of the plugin form as built
* by static::buildConfigurationForm().
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the complete form.
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* Form submission handler.
*
* @param array $form
* An associative array containing the structure of the plugin form as built
* by static::buildConfigurationForm().
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the complete form.
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this
->setConfiguration($form_state
->getValues());
}
/**
* {@inheritdoc}
*/
public function prepareEntityData(RuntimeImportContext $runtime_import_context, array &$entity_json_data) {
}
/**
* {@inheritdoc}
*/
public function isEntityImportable(RuntimeImportContext $runtime_import_context, array $entity_json_data) {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function prepareImportableEntityData(RuntimeImportContext $runtime_import_context, array &$entity_json_data) {
}
/**
* {@inheritdoc}
*/
public function processEntity(RuntimeImportContext $runtime_import_context, ContentEntityInterface $processed_entity, array $entity_json_data) {
}
/**
* {@inheritdoc}
*/
public function postEntitySave(RuntimeImportContext $runtime_import_context, ContentEntityInterface $processed_entity) {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
ImportProcessorInterface:: |
constant | Processing stage: is entity importable. | ||
ImportProcessorInterface:: |
constant | Processing stage: post entity save. | ||
ImportProcessorInterface:: |
constant | Processing stage: prepare entity data. | ||
ImportProcessorInterface:: |
constant | Processing stage: prepare importable entity data. | ||
ImportProcessorInterface:: |
constant | Processing stage: process entity. | ||
ImportProcessorPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
5 |
ImportProcessorPluginBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
3 |
ImportProcessorPluginBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Returns the plugin's description. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Returns the weight for a specific processing stage. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_IS_ENTITY_IMPORTABLE. Overrides ImportProcessorInterface:: |
2 |
ImportProcessorPluginBase:: |
public | function |
Determines whether this processor should always be enabled. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Returns the label for use on the administration pages. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_POST_ENTITY_SAVE. Overrides ImportProcessorInterface:: |
1 |
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_PREPARE_ENTITY_DATA. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_PREPARE_IMPORTABLE_ENTITY_DATA. Overrides ImportProcessorInterface:: |
4 |
ImportProcessorPluginBase:: |
public | function |
Method called on STAGE_PROCESS_ENTITY. Overrides ImportProcessorInterface:: |
4 |
ImportProcessorPluginBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
ImportProcessorPluginBase:: |
public | function |
Sets the weight for a specific processing stage. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function | Form submission handler. | |
ImportProcessorPluginBase:: |
public | function |
Checks whether this processor implements a particular stage. Overrides ImportProcessorInterface:: |
|
ImportProcessorPluginBase:: |
public | function | Form validation handler. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |