You are here

class FieldTargetDefinition in Feeds 8.3

Provides a field definition wrapped over a field definition.

Hierarchy

Expanded class hierarchy of FieldTargetDefinition

23 files declare their use of FieldTargetDefinition
ConfigEntityReference.php in src/Feeds/Target/ConfigEntityReference.php
DateRange.php in src/Feeds/Target/DateRange.php
Email.php in src/Feeds/Target/Email.php
EntityProcessorBase.php in src/Feeds/Processor/EntityProcessorBase.php
EntityProcessorBaseTest.php in tests/src/Kernel/Feeds/Processor/EntityProcessorBaseTest.php

... See full list

File

src/FieldTargetDefinition.php, line 10

Namespace

Drupal\feeds
View source
class FieldTargetDefinition extends TargetDefinition {

  /**
   * The target plugin id.
   *
   * @var string
   */
  protected $pluginId;

  /**
   * The wrapped field definition.
   *
   * @var \Drupal\Core\Field\FieldDefinitionInterface
   */
  protected $fieldDefinition;

  /**
   * Creates a target definition form a field definition.
   *
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
   *   The field definition.
   *
   * @return \Drupal\feeds\FieldTargetDefinition
   *   A new target definition.
   */
  public static function createFromFieldDefinition(FieldDefinitionInterface $field_definition) {
    return static::create()
      ->setFieldDefinition($field_definition);
  }

  /**
   * Sets the field definition.
   *
   * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
   *   The field definition.
   *
   * @return $this
   */
  protected function setFieldDefinition(FieldDefinitionInterface $field_definition) {
    $this->fieldDefinition = $field_definition;
    return $this;
  }

  /**
   * Sets the plugin id.
   *
   * @param string $plugin_id
   *   The plugin id.
   *
   * @return $this
   *   An instance of itself.
   */
  public function setPluginId($plugin_id) {
    $this->pluginId = $plugin_id;
    return $this;
  }

  /**
   * Returns the field definition.
   *
   * @return \Drupal\Core\Field\FieldDefinitionInterface
   *   The wrapped field definition.
   */
  public function getFieldDefinition() {
    return $this->fieldDefinition;
  }

  /**
   * {@inheritdoc}
   */
  public function getLabel() {
    return $this->fieldDefinition
      ->getLabel();
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->fieldDefinition
      ->getDescription();
  }

  /**
   * {@inheritdoc}
   */
  public function getPropertyLabel($property) {
    if (!empty($this->properties[$property]['label'])) {
      return $this->properties[$property]['label'];
    }
    $property_definition = $this->fieldDefinition
      ->getItemDefinition()
      ->getPropertyDefinition($property);
    return $property_definition ? $property_definition
      ->getLabel() : parent::getPropertyLabel($property);
  }

  /**
   * {@inheritdoc}
   */
  public function getPropertyDescription($property) {
    if (!empty($this->properties[$property]['description'])) {
      return $this->properties[$property]['description'];
    }
    $property_definition = $this->fieldDefinition
      ->getItemDefinition()
      ->getPropertyDefinition($property);
    return $property_definition ? $property_definition
      ->getDescription() : parent::getPropertyDescription($property);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FieldTargetDefinition::$fieldDefinition protected property The wrapped field definition.
FieldTargetDefinition::$pluginId protected property The target plugin id.
FieldTargetDefinition::createFromFieldDefinition public static function Creates a target definition form a field definition.
FieldTargetDefinition::getDescription public function Returns the target description. Overrides TargetDefinition::getDescription
FieldTargetDefinition::getFieldDefinition public function Returns the field definition.
FieldTargetDefinition::getLabel public function Returns the target label. Overrides TargetDefinition::getLabel
FieldTargetDefinition::getPropertyDescription public function Returns the description for a given property. Overrides TargetDefinition::getPropertyDescription
FieldTargetDefinition::getPropertyLabel public function Returns the label for a given property. Overrides TargetDefinition::getPropertyLabel
FieldTargetDefinition::setFieldDefinition protected function Sets the field definition.
FieldTargetDefinition::setPluginId public function Sets the plugin id. Overrides TargetDefinition::setPluginId
TargetDefinition::$description protected property The definition description.
TargetDefinition::$label protected property The definition label.
TargetDefinition::$properties protected property The definition properties.
TargetDefinition::$unique protected property The unique properties.
TargetDefinition::addProperty public function Adds a supported property.
TargetDefinition::create public static function Helper factory method. Overrides TargetDefinitionInterface::create
TargetDefinition::getPluginId public function Returns the target plugin id. Overrides TargetDefinitionInterface::getPluginId
TargetDefinition::getProperties public function Returns the list of properties. Overrides TargetDefinitionInterface::getProperties
TargetDefinition::hasProperty public function Returns whether this target has a given property. Overrides TargetDefinitionInterface::hasProperty
TargetDefinition::isUnique public function Retuns whether a property is unique. Overrides TargetDefinitionInterface::isUnique
TargetDefinition::markPropertyUnique public function Marks a property as unique.
TargetDefinition::setDescription public function Sets the target definition description.
TargetDefinition::setLabel public function Sets the target definition label.