You are here

class TargetDefinition in Feeds 8.3

A generic target definition.

Hierarchy

Expanded class hierarchy of TargetDefinition

2 files declare their use of TargetDefinition
TargetDefinitionTest.php in tests/src/Unit/TargetDefinitionTest.php
Temporary.php in src/Feeds/Target/Temporary.php

File

src/TargetDefinition.php, line 8

Namespace

Drupal\feeds
View source
class TargetDefinition implements TargetDefinitionInterface {

  /**
   * The definition label.
   *
   * @var string
   */
  protected $label;

  /**
   * The definition description.
   *
   * @var string
   */
  protected $description;

  /**
   * The definition properties.
   *
   * @var array
   */
  protected $properties = [];

  /**
   * The unique properties.
   *
   * @var array
   */
  protected $unique = [];

  /**
   * {@inheritdoc}
   */
  public static function create() {
    return new static();
  }

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

  /**
   * {@inheritdoc}
   */
  public function setPluginId($plugin_id) {
    $this->pluginId = $plugin_id;
    return $this;
  }

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

  /**
   * Sets the target definition label.
   *
   * @param string $label
   *   The label.
   *
   * @return $this
   */
  public function setLabel($label) {
    $this->label = $label;
    return $this;
  }

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

  /**
   * Sets the target definition description.
   *
   * @param string $description
   *   The description.
   *
   * @return $this
   */
  public function setDescription($description) {
    $this->description = $description;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function hasProperty($property) {
    return isset($this->properties[$property]);
  }

  /**
   * {@inheritdoc}
   */
  public function getProperties() {
    return array_keys($this->properties);
  }

  /**
   * {@inheritdoc}
   */
  public function getPropertyLabel($property) {
    return $this->properties[$property]['label'];
  }

  /**
   * {@inheritdoc}
   */
  public function getPropertyDescription($property) {
    return $this->properties[$property]['description'];
  }

  /**
   * {@inheritdoc}
   */
  public function isUnique($property) {
    return isset($this->unique[$property]);
  }

  /**
   * Adds a supported property.
   *
   * @param string $property
   *   The supported property.
   * @param string $label
   *   (optional) The label of the property. Defaults to an empty string.
   * @param string $description
   *   (optional) The description of the property. Defaults to an empty string.
   *
   * @return $this
   */
  public function addProperty($property, $label = '', $description = '') {
    $this->properties[$property] = [
      'label' => $label,
      'description' => $description,
    ];
    return $this;
  }

  /**
   * Marks a property as unique.
   *
   * @param string $property
   *   The property to mark as unique.
   *
   * @return $this
   */
  public function markPropertyUnique($property) {
    $this->unique[$property] = TRUE;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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::getDescription public function Returns the target description. Overrides TargetDefinitionInterface::getDescription 1
TargetDefinition::getLabel public function Returns the target label. Overrides TargetDefinitionInterface::getLabel 1
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::getPropertyDescription public function Returns the description for a given property. Overrides TargetDefinitionInterface::getPropertyDescription 1
TargetDefinition::getPropertyLabel public function Returns the label for a given property. Overrides TargetDefinitionInterface::getPropertyLabel 1
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.
TargetDefinition::setPluginId public function 1