ImportProcessorPluginBase.php in Entity Share 8.3
File
modules/entity_share_client/src/ImportProcessor/ImportProcessorPluginBase.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_share_client\ImportProcessor;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\entity_share_client\RuntimeImportContext;
use Symfony\Component\DependencyInjection\ContainerInterface;
abstract class ImportProcessorPluginBase extends PluginBase implements ImportProcessorInterface, ContainerFactoryPluginInterface {
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition);
}
public function label() {
$plugin_definition = $this
->getPluginDefinition();
$label = $plugin_definition['label'];
if ($label instanceof TranslatableMarkup) {
$label = $label
->render();
}
return $label;
}
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;
}
public function defaultConfiguration() {
return [];
}
public function getConfiguration() {
return $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
public function supportsStage($stage) {
$plugin_definition = $this
->getPluginDefinition();
return isset($plugin_definition['stages'][$stage]);
}
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;
}
public function setWeight($stage, $weight) {
$this->configuration['weights'][$stage] = $weight;
return $this;
}
public function isLocked() {
return !empty($this->pluginDefinition['locked']);
}
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
$this
->setConfiguration($form_state
->getValues());
}
public function prepareEntityData(RuntimeImportContext $runtime_import_context, array &$entity_json_data) {
}
public function isEntityImportable(RuntimeImportContext $runtime_import_context, array $entity_json_data) {
return TRUE;
}
public function prepareImportableEntityData(RuntimeImportContext $runtime_import_context, array &$entity_json_data) {
}
public function processEntity(RuntimeImportContext $runtime_import_context, ContentEntityInterface $processed_entity, array $entity_json_data) {
}
public function postEntitySave(RuntimeImportContext $runtime_import_context, ContentEntityInterface $processed_entity) {
}
}