W3cubDocs

/Drupal 8

public function ImageToolkitBase::apply

public ImageToolkitBase::apply($operation, array $arguments = array())

Applies a toolkit operation to an image.

Parameters

string $operation: The toolkit operation to be processed.

array $arguments: An associative array of arguments to be passed to the toolkit operation, e.g. array('width' => 50, 'height' => 100, 'upscale' => TRUE).

Return value

bool TRUE if the operation was performed successfully, FALSE otherwise.

Overrides ImageToolkitInterface::apply

File

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

Class

ImageToolkitBase
Provides a base class for image toolkit plugins.

Namespace

Drupal\Core\ImageToolkit

Code

public function apply($operation, array $arguments = array()) {
  try {
    // Get the plugin to use for the operation and apply the operation.
    return $this->getToolkitOperation($operation)->apply($arguments);
  }
  catch (PluginNotFoundException $e) {
    $this->logger->error("The selected image handling toolkit '@toolkit' can not process operation '@operation'.", array('@toolkit' => $this->getPluginId(), '@operation' => $operation));
    return FALSE;
  }
  catch (\InvalidArgumentException $e) {
    $this->logger->warning($e->getMessage(), array());
    return FALSE;
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!ImageToolkit!ImageToolkitBase.php/function/ImageToolkitBase::apply/8.1.x