You are here

class ArrayDeprecationWrapper in Entity Construction Kit (ECK) 8

Class ArrayDeprecationWrapper

@package Drupal\eck

Hierarchy

Expanded class hierarchy of ArrayDeprecationWrapper

1 file declares its use of ArrayDeprecationWrapper
eck.module in ./eck.module
Contains hook implementations.

File

src/ArrayDeprecationWrapper.php, line 12

Namespace

Drupal\eck
View source
class ArrayDeprecationWrapper implements \ArrayAccess, RenderableInterface {

  /**
   * The deprecated array.
   *
   * @var array
   */
  private $wrappedArray;

  /**
   * The deprecation warning to set.
   *
   * @var string
   */
  private $deprecationWarning;

  /**
   * ArrayDeprecationWrapper constructor.
   *
   * @param array $wrappedArray
   *   The array being deprecated.
   * @param $deprecationWarning
   *   The warning that should be raised when it is accessed.
   */
  public function __construct(array &$wrappedArray, $deprecationWarning) {
    $this->wrappedArray = $wrappedArray;
    $this->deprecationWarning = $deprecationWarning;
  }

  /**
   * {@inheritdoc}
   */
  public function offsetExists($offset) {
    trigger_error($this->deprecationWarning, E_USER_DEPRECATED);
    return isset($this->wrappedArray[$offset]);
  }

  /**
   * {@inheritdoc}
   */
  public function offsetGet($offset) {
    trigger_error($this->deprecationWarning, E_USER_DEPRECATED);
    return $this->wrappedArray[$offset];
  }

  /**
   * {@inheritdoc}
   */
  public function offsetSet($offset, $value) {
    trigger_error($this->deprecationWarning, E_USER_DEPRECATED);
    $this->wrappedArray[$offset] = $value;
  }

  /**
   * {@inheritdoc}
   */
  public function offsetUnset($offset) {
    trigger_error($this->deprecationWarning, E_USER_DEPRECATED);
    unset($this->wrappedArray[$offset]);
  }

  /**
   * Returns a render array representation of the object.
   *
   * @return mixed[]
   *   A render array.
   */
  public function toRenderable() {
    trigger_error($this->deprecationWarning, E_USER_DEPRECATED);
    return $this->wrappedArray;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ArrayDeprecationWrapper::$deprecationWarning private property The deprecation warning to set.
ArrayDeprecationWrapper::$wrappedArray private property The deprecated array.
ArrayDeprecationWrapper::offsetExists public function
ArrayDeprecationWrapper::offsetGet public function
ArrayDeprecationWrapper::offsetSet public function
ArrayDeprecationWrapper::offsetUnset public function
ArrayDeprecationWrapper::toRenderable public function Returns a render array representation of the object. Overrides RenderableInterface::toRenderable
ArrayDeprecationWrapper::__construct public function ArrayDeprecationWrapper constructor.