Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Plugin / Context / ContextInterface.php
1 <?php
2
3 namespace Drupal\Core\Plugin\Context;
4
5 use Drupal\Component\Plugin\Context\ContextInterface as ComponentContextInterface;
6 use Drupal\Core\Cache\CacheableDependencyInterface;
7
8 /**
9  * Context data and definitions for plugins supporting caching and return docs.
10  *
11  * @see \Drupal\Component\Plugin\Context\ContextInterface
12  * @see \Drupal\Core\Plugin\Context\ContextDefinitionInterface
13  */
14 interface ContextInterface extends ComponentContextInterface, CacheableDependencyInterface {
15
16   /**
17    * {@inheritdoc}
18    *
19    * @return \Drupal\Core\Plugin\Context\ContextDefinitionInterface
20    */
21   public function getContextDefinition();
22
23   /**
24    * Gets the context value as typed data object.
25    *
26    * @return \Drupal\Core\TypedData\TypedDataInterface
27    */
28   public function getContextData();
29
30   /**
31    * Adds a dependency on an object: merges its cacheability metadata.
32    *
33    * For example, when a context depends on some configuration, an entity, or an
34    * access result, we must make sure their cacheability metadata is present on
35    * the response. This method makes doing that simple.
36    *
37    * @param \Drupal\Core\Cache\CacheableDependencyInterface|mixed $dependency
38    *   The dependency. If the object implements CacheableDependencyInterface,
39    *   then its cacheability metadata will be used. Otherwise, the passed in
40    *   object must be assumed to be uncacheable, so max-age 0 is set.
41    *
42    * @return $this
43    *
44    * @see \Drupal\Core\Cache\CacheableMetadata::createFromObject()
45    */
46   public function addCacheableDependency($dependency);
47
48   /**
49    * Creates a new context with a different value.
50    *
51    * @param \Drupal\Core\Plugin\Context\ContextInterface $old_context
52    *   The context object used to create a new object. Cacheability metadata
53    *   will be copied over.
54    * @param mixed $value
55    *   The value of the new context object.
56    *
57    * @return static
58    */
59   public static function createFromContext(ContextInterface $old_context, $value);
60
61 }