class ContextDefinition

Same name in this branch
  1. 8.x-3.x src/Context/ContextDefinition.php \Drupal\rules\Context\ContextDefinition

Extends the core context definition annotation object for Rules.

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

Hierarchy

Expanded class hierarchy of ContextDefinition

File

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

Namespace

Drupal\rules\Context\Annotation
View source
class ContextDefinition extends CoreContextDefinition {
    
    /**
     * The ContextDefinitionInterface object.
     *
     * @var \Drupal\rules\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 = RulesContextDefinition::createFromArray($values);
    }
    
    /**
     * Returns the value of an annotation.
     *
     * @return \Drupal\rules\Context\ContextDefinitionInterface
     *   Return the Rules version of the ContextDefinitionInterface.
     */
    public function get() {
        return $this->definition;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title 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 1
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 1
Plugin::parse protected function Parses an annotation into its definition.
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass 1
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider