ContextInterface.php

Same filename in this branch
  1. 10 core/lib/Drupal/Core/Plugin/Context/ContextInterface.php
Same filename in other branches
  1. 9 core/lib/Drupal/Core/Plugin/Context/ContextInterface.php
  2. 9 core/lib/Drupal/Component/Plugin/Context/ContextInterface.php
  3. 8.9.x core/lib/Drupal/Core/Plugin/Context/ContextInterface.php
  4. 8.9.x core/lib/Drupal/Component/Plugin/Context/ContextInterface.php
  5. 11.x core/lib/Drupal/Core/Plugin/Context/ContextInterface.php
  6. 11.x core/lib/Drupal/Component/Plugin/Context/ContextInterface.php

Namespace

Drupal\Component\Plugin\Context

File

core/lib/Drupal/Component/Plugin/Context/ContextInterface.php

View source
<?php

namespace Drupal\Component\Plugin\Context;


/**
 * Provides data and definitions for plugins during runtime and administration.
 *
 * Plugin contexts are satisfied by ContextInterface implementing objects.
 * These objects always contain a definition of what data they will provide
 * during runtime. During run time, ContextInterface implementing objects must
 * also provide the corresponding data value.
 *
 * @see \Drupal\Component\Plugin\Context\ContextDefinitionInterface
 */
interface ContextInterface {
    
    /**
     * Gets the context value.
     *
     * @return mixed
     *   The currently set context value, or NULL if it is not set.
     */
    public function getContextValue();
    
    /**
     * Returns whether the context has a value.
     *
     * @return bool
     *   TRUE if the context has a value, FALSE otherwise.
     */
    public function hasContextValue();
    
    /**
     * Gets the provided definition that the context must conform to.
     *
     * @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
     *   The defining characteristic representation of the context.
     */
    public function getContextDefinition();
    
    /**
     * Gets a list of validation constraints.
     *
     * @return array
     *   Array of constraints, each being an instance of
     *   \Symfony\Component\Validator\Constraint.
     */
    public function getConstraints();
    
    /**
     * Validates the set context value.
     *
     * @return \Symfony\Component\Validator\ConstraintViolationListInterface
     *   A list of constraint violations. If the list is empty, validation
     *   succeeded.
     */
    public function validate();

}

Interfaces

Title Deprecated Summary
ContextInterface Provides data and definitions for plugins during runtime and administration.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.