public function Binary::setValue

Overrides TypedData::setValue().

Supports a PHP file resource or a (absolute) stream resource URI as value.

Overrides TypedData::setValue

File

drupal/core/lib/Drupal/Core/TypedData/Type/Binary.php, line 53
Contains \Drupal\Core\TypedData\Type\Binary.

Class

Binary
The binary data type.

Namespace

Drupal\Core\TypedData\Type

Code

public function setValue($value, $notify = TRUE) {

  // Notify the parent of any changes to be made.
  if ($notify && isset($this->parent)) {
    $this->parent
      ->onChange($this->name);
  }
  if (!isset($value)) {
    $this->handle = NULL;
    $this->uri = NULL;
  }
  elseif (is_string($value)) {

    // Note: For performance reasons we store the given URI and access the
    // resource upon request. See Binary::getValue()
    $this->uri = $value;
    $this->handle = NULL;
  }
  else {
    $this->handle = $value;
  }
}