TypedDataEntityRelationship.php in Chaos Tool Suite (ctools) 8.3
File
src/Plugin/Relationship/TypedDataEntityRelationship.php
View source
<?php
namespace Drupal\ctools\Plugin\Relationship;
use Drupal\Core\Plugin\Context\Context;
use Drupal\Core\Plugin\Context\EntityContextDefinition;
class TypedDataEntityRelationship extends TypedDataRelationship {
public function getRelationship() {
$plugin_definition = $this
->getPluginDefinition();
$entity_type = $this
->getData($this
->getContext('base'))
->getDataDefinition()
->getSetting('target_type');
$context_definition = new EntityContextDefinition("entity:{$entity_type}", $plugin_definition['label']);
$context_value = NULL;
if ($this
->getContext('base')
->hasContextValue()) {
$context_value = $this
->getData($this
->getContext('base'))->entity;
}
$context_definition
->setDefaultValue($context_value);
return new Context($context_definition, $context_value);
}
}
Classes
Name |
Description |
TypedDataEntityRelationship |
Plugin annotation
@Relationship(
id = "typed_data_entity_relationship",
deriver = "\Drupal\ctools\Plugin\Deriver\TypedDataEntityRelationshipDeriver"
) |