You are here

class TamperableComplexDataAdapter in Tamper 8

Provides an adapter to use complex typed data as a tamperable item.

Hierarchy

Expanded class hierarchy of TamperableComplexDataAdapter

1 file declares its use of TamperableComplexDataAdapter
TamperableComplexDataAdapterTest.php in tests/src/Unit/Adapter/TamperableComplexDataAdapterTest.php

File

src/Adapter/TamperableComplexDataAdapter.php, line 11

Namespace

Drupal\tamper\Adapter
View source
class TamperableComplexDataAdapter implements TamperableItemInterface {

  /**
   * Typed complex data object.
   *
   * @var \Drupal\Core\TypedData\ComplexDataInterface
   */
  protected $complexData;

  /**
   * Create a new instance of the adapter.
   *
   * @param \Drupal\Core\TypedData\ComplexDataInterface $complexData
   *   Typed complex data object.
   */
  public function __construct(ComplexDataInterface $complexData) {
    $this->complexData = $complexData;
  }

  /**
   * {@inheritdoc}
   */
  public function getSource($include_computed = FALSE) {
    return $this->complexData
      ->toArray();
  }

  /**
   * {@inheritdoc}
   */
  public function setSourceProperty($property, $data) {
    $this->complexData
      ->set($property, $data);
  }

  /**
   * {@inheritdoc}
   */
  public function getSourceProperty($property) {
    return $this->complexData
      ->get($property);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TamperableComplexDataAdapter::$complexData protected property Typed complex data object.
TamperableComplexDataAdapter::getSource public function Returns the whole item as an array. Overrides TamperableItemInterface::getSource
TamperableComplexDataAdapter::getSourceProperty public function Retrieves a source property. Overrides TamperableItemInterface::getSourceProperty
TamperableComplexDataAdapter::setSourceProperty public function Sets a source property. Overrides TamperableItemInterface::setSourceProperty
TamperableComplexDataAdapter::__construct public function Create a new instance of the adapter.