You are here

public function ImageFieldMapping::__construct in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x src/FieldMapping/ImageFieldMapping.php \Drupal\fillpdf\FieldMapping\ImageFieldMapping::__construct()

Constructs an ImageFieldMapping object.

Parameters

string $data: String containing the image data, as returned by file_get_contents() and not encoded.

string $extension: (optional) The original extension corresponding to the image data. If the backend doesn't need to know the extension and you don't want extensions to be checked, you can leave it blank.

string $uri: (optional) URI of the image.

Throws

\InvalidArgumentException If the extension isn't one of 'jpg', 'png', or 'gif'.

Overrides FieldMapping::__construct

File

src/FieldMapping/ImageFieldMapping.php, line 47

Class

ImageFieldMapping
Represents a mapping between a PDF image field and a merge value.

Namespace

Drupal\fillpdf\FieldMapping

Code

public function __construct($data, $extension = NULL, $uri = NULL) {
  parent::__construct($data);
  if (isset($extension) && !in_array($extension, [
    'jpg',
    'png',
    'gif',
  ])) {
    throw new \InvalidArgumentException('Extension must be one of: jpg, png, gif.');
  }
  $this->extension = $extension;
  $this->uri = $uri;
}