You are here

public function Textimage::setTargetExtension in Textimage 8.4

Same name and namespace in other branches
  1. 8.3 src/Textimage.php \Drupal\textimage\Textimage::setTargetExtension()

Sets the image file extension.

Parameters

string $extension: The file extension to be used (e.g. jpeg/png/gif).

Return value

$this

Overrides TextimageInterface::setTargetExtension

2 calls to Textimage::setTargetExtension()
Textimage::process in src/Textimage.php
Process the Textimage, with the required raw text.
Textimage::setTargetUri in src/Textimage.php
Set image destination URI.

File

src/Textimage.php, line 320

Class

Textimage
Provides a Textimage.

Namespace

Drupal\textimage

Code

public function setTargetExtension($extension) {
  if ($this->extension) {
    throw new TextimageException("Extension already set");
  }
  $extension = strtolower($extension);
  if (!in_array($extension, $this->imageFactory
    ->getSupportedExtensions())) {
    $this->logger
      ->error("Unsupported image file extension (%extension) requested.", [
      '%extension' => $extension,
    ]);
    throw new TextimageException("Attempted to set an unsupported file image extension ({$extension})");
  }
  return $this
    ->set('extension', $extension);
}