3 namespace Drupal\ctools\Plugin\Relationship;
4 use Drupal\Core\Plugin\Context\Context;
5 use Drupal\Core\Plugin\Context\ContextDefinition;
9 * id = "typed_data_language_relationship",
10 * deriver = "\Drupal\ctools\Plugin\Deriver\TypedDataLanguageRelationshipDeriver"
13 class TypedDataLanguageRelationship extends TypedDataRelationship {
18 public function getRelationship() {
19 $plugin_definition = $this->getPluginDefinition();
21 $context_definition = new ContextDefinition("language", $plugin_definition['label']);
22 $context_value = NULL;
24 // If the 'base' context has a value, then get the property value to put on
25 // the context (otherwise, mapping hasn't occurred yet and we just want to
26 // return the context with the right definition and no value).
27 if ($this->getContext('base')->hasContextValue()) {
28 $context_value = $this->getData($this->getContext('base'))->language;
31 $context_definition->setDefaultValue($context_value);
32 return new Context($context_definition, $context_value);