function ImageToolkitBase::setSource

Same name in other branches
  1. 9 core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php \Drupal\Core\ImageToolkit\ImageToolkitBase::setSource()
  2. 8.9.x core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php \Drupal\Core\ImageToolkit\ImageToolkitBase::setSource()
  3. 11.x core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php \Drupal\Core\ImageToolkit\ImageToolkitBase::setSource()

Overrides ImageToolkitInterface::setSource

File

core/lib/Drupal/Core/ImageToolkit/ImageToolkitBase.php, line 80

Class

ImageToolkitBase
Provides a base class for image toolkit plugins.

Namespace

Drupal\Core\ImageToolkit

Code

public function setSource($source) {
    // If a previous image has been loaded, there is no way to know if the
    // toolkit implementation needs to perform any additional actions like
    // freeing memory. Therefore, the source image cannot be changed once set.
    if ($this->source) {
        throw new \BadMethodCallException(__METHOD__ . '() may only be called once');
    }
    $this->source = $source;
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.