Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContextStorage.php

class ContextStorage

@internal

Hierarchy

  • class \OpenTelemetry\Context\ContextStorage implements \OpenTelemetry\Context\ContextStorageInterface, \OpenTelemetry\Context\ContextStorageHeadAware, \OpenTelemetry\Context\ExecutionContextAwareInterface

Expanded class hierarchy of ContextStorage

File

vendor/open-telemetry/context/ContextStorage.php, line 10

Namespace

OpenTelemetry\Context
View source
final class ContextStorage implements ContextStorageInterface, ContextStorageHeadAware, ExecutionContextAwareInterface {
    private ContextStorageHead $current;
    private ContextStorageHead $main;
    
    /** @var array<int|string, ContextStorageHead> */
    private array $forks = [];
    public function __construct() {
        $this->current = $this->main = new ContextStorageHead($this);
    }
    public function fork(int|string $id) : void {
        $this->forks[$id] = clone $this->current;
    }
    public function switch(int|string $id) : void {
        $this->current = $this->forks[$id] ?? $this->main;
    }
    public function destroy(int|string $id) : void {
        unset($this->forks[$id]);
    }
    public function head() : ContextStorageHead {
        return $this->current;
    }
    public function scope() : ?ContextStorageScopeInterface {
        return ($this->current->node->head ?? null) === $this->current ? $this->current->node : null;
    }
    public function current() : ContextInterface {
        return $this->current->node->context ?? Context::getRoot();
    }
    public function attach(ContextInterface $context) : ContextStorageScopeInterface {
        return $this->current->node = new ContextStorageNode($context, $this->current, $this->current->node);
    }
    private function __clone() {
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
ContextStorage::$current private property
ContextStorage::$forks private property @var array&lt;int|string, ContextStorageHead&gt;
ContextStorage::$main private property
ContextStorage::attach public function Attaches the context as active context. Overrides ContextStorageInterface::attach
ContextStorage::current public function Returns the current context. Overrides ContextStorageInterface::current
ContextStorage::destroy public function Overrides ExecutionContextAwareInterface::destroy
ContextStorage::fork public function Overrides ExecutionContextAwareInterface::fork
ContextStorage::head public function Overrides ContextStorageHeadAware::head
ContextStorage::scope public function Returns the current scope. Overrides ContextStorageInterface::scope
ContextStorage::switch public function Overrides ExecutionContextAwareInterface::switch
ContextStorage::__clone private function
ContextStorage::__construct public function

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal