You are here

class ContextDefinition in Typed Data API enhancements 8

Same name in this branch
  1. 8 src/Context/ContextDefinition.php \Drupal\typed_data\Context\ContextDefinition
  2. 8 src/Context/Annotation/ContextDefinition.php \Drupal\typed_data\Context\Annotation\ContextDefinition

Extends the core context definition annotation object for Typed Data.

Ensures context definitions use \Drupal\typed_data\Context\ContextDefinitionInterface.

Hierarchy

Expanded class hierarchy of ContextDefinition

File

src/Context/Annotation/ContextDefinition.php, line 19

Namespace

Drupal\typed_data\Context\Annotation
View source
class ContextDefinition extends CoreContextDefinition {

  /**
   * The ContextDefinitionInterface object.
   *
   * @var \Drupal\typed_data\Context\ContextDefinitionInterface
   */
  protected $definition;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $values) {

    // Filter out any @Translation annotation objects.
    foreach ($values as $key => $value) {
      if ($value instanceof Translation) {
        $values[$key] = $value
          ->get();
      }
    }
    $this->definition = TypedDataContextDefinition::createFromArray($values);
  }

  /**
   * Returns the value of an annotation.
   *
   * @return \Drupal\typed_data\Context\ContextDefinitionInterface
   *   Return the Typed Data version of the ContextDefinitionInterface.
   */
  public function get() {
    return $this->definition;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContextDefinition::$definition protected property The ContextDefinitionInterface object. Overrides ContextDefinition::$definition
ContextDefinition::get public function Returns the value of an annotation. Overrides ContextDefinition::get
ContextDefinition::getDefinitionClass protected function Determines the context definition class to use.
ContextDefinition::__construct public function Constructs a new context definition object. Overrides ContextDefinition::__construct
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass
Plugin::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId
Plugin::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider
Plugin::parse protected function Parses an annotation into its definition.
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider