abstract class ParagraphsConversionBase

Provides a base class for paragraphs conversions.

Hierarchy

Expanded class hierarchy of ParagraphsConversionBase

3 files declare their use of ParagraphsConversionBase
ParagraphsDemoUserText.php in paragraphs/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserText.php
ParagraphsDemoUserToTextUser.php in paragraphs/modules/paragraphs_demo/src/Plugin/paragraphs/Conversion/ParagraphsDemoUserToTextUser.php
ParagraphsTestTextToTextImage.php in paragraphs/tests/modules/paragraphs_test/src/Plugin/paragraphs/Conversion/ParagraphsTestTextToTextImage.php

File

paragraphs/src/ParagraphsConversionBase.php, line 13

Namespace

Drupal\paragraphs
View source
abstract class ParagraphsConversionBase extends PluginBase implements ParagraphsConversionInterface, ContainerFactoryPluginInterface {

  /**
   * Constructs a ParagraphsBehaviorBase object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->configuration += $this
      ->defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition);
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@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 calculateDependencies() {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConversionForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function validateConversionForm(ParagraphInterface $paragraph, array &$form, FormStateInterface $form_state) {
  }

  /**
   * {@inheritdoc}
   */
  public function convert(array $settings, ParagraphInterface $original_paragraph, array $converted_paragraph = NULL) {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function supports(ParagraphInterface $paragraph, array $parent_allowed_types = NULL) {
    return $paragraph
      ->getType() == $this
      ->getPluginDefinition()['source_type'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ParagraphsConversionBase::buildConfigurationForm public function
ParagraphsConversionBase::buildConversionForm public function Builds a conversion form to add extra settings to the conversion. Overrides ParagraphsConversionInterface::buildConversionForm 1
ParagraphsConversionBase::calculateDependencies public function
ParagraphsConversionBase::convert public function Submit the values taken from the form to store the values. Overrides ParagraphsConversionInterface::convert 2
ParagraphsConversionBase::create public static function
ParagraphsConversionBase::defaultConfiguration public function
ParagraphsConversionBase::getConfiguration public function
ParagraphsConversionBase::setConfiguration public function
ParagraphsConversionBase::submitConfigurationForm public function
ParagraphsConversionBase::supports public function Check if the current plugin supports conversion for a paragraph. Overrides ParagraphsConversionInterface::supports
ParagraphsConversionBase::validateConfigurationForm public function
ParagraphsConversionBase::validateConversionForm public function Validates the conversion fields form. Overrides ParagraphsConversionInterface::validateConversionForm
ParagraphsConversionBase::__construct public function Constructs a ParagraphsBehaviorBase object.