class ImageFieldMapping in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/FieldMapping/ImageFieldMapping.php \Drupal\fillpdf\FieldMapping\ImageFieldMapping
Represents a mapping between a PDF image field and a merge value.
ImageFieldMapping objects are immutable; replace the value by calling the constructor again if the value needs to change.
Hierarchy
- class \Drupal\fillpdf\FieldMapping
- class \Drupal\fillpdf\FieldMapping\ImageFieldMapping
Expanded class hierarchy of ImageFieldMapping
5 files declare their use of ImageFieldMapping
- FillPdfServicePdfBackend.php in src/
Plugin/ PdfBackend/ FillPdfServicePdfBackend.php - ImageFieldMappingTest.php in tests/
src/ Unit/ FieldMapping/ ImageFieldMappingTest.php - LocalServerPdfBackend.php in src/
Plugin/ PdfBackend/ LocalServerPdfBackend.php - PdfPopulationTest.php in tests/
src/ Functional/ PdfPopulationTest.php - TokenResolver.php in src/
TokenResolver.php
File
- src/
FieldMapping/ ImageFieldMapping.php, line 13
Namespace
Drupal\fillpdf\FieldMappingView source
class ImageFieldMapping extends FieldMapping {
/**
* The image file's extension.
*
* May be 'jpg', 'png', or 'gif'.
*
* @var string
*/
protected $extension;
/**
* The image file's URI.
*
* @var string
*/
protected $uri;
/**
* Constructs an ImageFieldMapping object.
*
* @param string $data
* String containing the image data, as returned by file_get_contents() and
* not encoded.
* @param 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.
* @param string $uri
* (optional) URI of the image.
*
* @throws \InvalidArgumentException
* If the extension isn't one of 'jpg', 'png', or 'gif'.
*/
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;
}
/**
* Gets the image file's extension.
*
* @return string
* The file's extension.
*/
public function getExtension() {
return $this->extension;
}
/**
* Gets the image file's URI.
*
* @return string
* The file's URI.
*/
public function getUri() {
return $this->uri;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldMapping:: |
protected | property | The primary value of the mapping. | |
FieldMapping:: |
public | function | Returns the data. | |
ImageFieldMapping:: |
protected | property | The image file's extension. | |
ImageFieldMapping:: |
protected | property | The image file's URI. | |
ImageFieldMapping:: |
public | function | Gets the image file's extension. | |
ImageFieldMapping:: |
public | function | Gets the image file's URI. | |
ImageFieldMapping:: |
public | function |
Constructs an ImageFieldMapping object. Overrides FieldMapping:: |