You are here

class ProcessingContext in YAML Content 8

The contextual data for content being actively loaded.

Hierarchy

Expanded class hierarchy of ProcessingContext

7 files declare their use of ProcessingContext
ContentLoader.php in src/ContentLoader/ContentLoader.php
File.php in src/Plugin/yaml_content/process/File.php
FileTest.php in tests/src/Functional/Plugin/yaml_content/process/FileTest.php
FileTest.php in tests/src/Unit/Plugin/yaml_content/process/FileTest.php
Reference.php in src/Plugin/yaml_content/process/Reference.php

... See full list

File

src/Plugin/ProcessingContext.php, line 11

Namespace

Drupal\yaml_content\Plugin
View source
class ProcessingContext {

  /**
   * The field currently being processed.
   *
   * @var \Drupal\Core\Field\FieldItemListInterface
   */
  protected $field;

  /**
   * The active content loader instance.
   *
   * @var \Drupal\yaml_content\ContentLoader\ContentLoaderInterface
   */
  protected $contentLoader;

  /**
   * Set the field context.
   *
   * @param \Drupal\Core\Field\FieldItemListInterface $field
   *   The field currently being processed.
   */
  public function setField(FieldItemListInterface $field) {
    $this->field = $field;
  }

  /**
   * Get the field context.
   *
   * @return \Drupal\Core\Field\FieldItemListInterface
   *   The field currently being processed.
   */
  public function getField() {
    if (!isset($this->field)) {

      // @todo Impelment a more specific exception.
      throw new \Exception('Missing field context.');
    }
    return $this->field;
  }

  /**
   * Set the content loader context.
   *
   * @param \Drupal\yaml_content\ContentLoader\ContentLoaderInterface $contentLoader
   *   The content loader instance actively loading content.
   */
  public function setContentLoader(ContentLoaderInterface $contentLoader) {
    $this->contentLoader = $contentLoader;
  }

  /**
   * Get the content loader context.
   *
   * @return \Drupal\yaml_content\ContentLoader\ContentLoaderInterface
   *   The content loader instance actively loading content.
   */
  public function getContentLoader() {
    if (!isset($this->contentLoader)) {

      // @todo Impelment a more specific exception.
      throw new \Exception('Missing content loader context.');
    }
    return $this->contentLoader;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ProcessingContext::$contentLoader protected property The active content loader instance.
ProcessingContext::$field protected property The field currently being processed.
ProcessingContext::getContentLoader public function Get the content loader context.
ProcessingContext::getField public function Get the field context.
ProcessingContext::setContentLoader public function Set the content loader context.
ProcessingContext::setField public function Set the field context.