You are here

public function TextimageFactory::setState in Textimage 8.3

Same name and namespace in other branches
  1. 8.4 src/TextimageFactory.php \Drupal\textimage\TextimageFactory::setState()

Sets a Textimage state variable.

@todo (core) remove when #1826362 (ImageStyle to be accessible from ImageEffect plugins) is committed.

Parameters

string $variable: State variable.

mixed $value: Value to set, or NULL to return current value.

Return value

mixed Property value.

1 call to TextimageFactory::setState()
TextimageFactory::getState in src/TextimageFactory.php
Gets a Textimage state variable.

File

src/TextimageFactory.php, line 162

Class

TextimageFactory
Provides a factory for Textimage.

Namespace

Drupal\textimage

Code

public function setState($variable = NULL, $value = NULL) {
  static $keys;
  if (!isset($keys) or !$variable) {
    $keys = [];
  }
  if ($variable) {
    if ($value) {
      $keys[$variable] = $value;
      return $value;
    }
    else {
      return isset($keys[$variable]) ? $keys[$variable] : NULL;
    }
  }
}