You are here

protected function TypedDataRelationship::getData in Chaos Tool Suite (ctools) 8.3

1 call to TypedDataRelationship::getData()
TypedDataRelationship::getRelationship in src/Plugin/Relationship/TypedDataRelationship.php
Generates a context based on this plugin's configuration.

File

src/Plugin/Relationship/TypedDataRelationship.php, line 56

Class

TypedDataRelationship
Plugin annotation @Relationship( id = "typed_data_relationship", deriver = "\Drupal\ctools\Plugin\Deriver\TypedDataRelationshipDeriver" )

Namespace

Drupal\ctools\Plugin\Relationship

Code

protected function getData(ContextInterface $context) {

  /** @var \Drupal\Core\TypedData\ComplexDataInterface $base */
  $base = $context
    ->getContextValue();
  $name = $this
    ->getPluginDefinition()['property_name'];
  $data = $base
    ->get($name);

  // @todo add configuration to get N instead of first.
  if ($data instanceof ListInterface) {
    $data = $data
      ->first();
  }
  if ($data instanceof DataReferenceInterface) {
    $data = $data
      ->getTarget();
  }
  return $data;
}