public function Textimage::load in Textimage 8.4
Same name and namespace in other branches
- 8.3 src/Textimage.php \Drupal\textimage\Textimage::load()
Load Textimage metadata from cache.
Parameters
string $id: The id of the Textimage to load.
Return value
bool TRUE if cache entry exists, FALSE otherwise.
Overrides TextimageInterface::load
File
- src/
Textimage.php, line 461
Class
- Textimage
- Provides a Textimage.
Namespace
Drupal\textimageCode
public function load($id) {
// Do not re-process.
if ($this->processed) {
return $this;
}
// Load from the cache.
$this->id = $id;
if ($cached_data = $this
->getCachedData()) {
$this
->set('imageData', $cached_data['imageData']);
$this
->set('uri', $cached_data['uri']);
$this
->set('width', $cached_data['width']);
$this
->set('height', $cached_data['height']);
$this
->set('effects', $cached_data['effects']);
$this
->set('text', $cached_data['imageData']['text']);
$this
->set('extension', $cached_data['imageData']['extension']);
if ($cached_data['imageData']['sourceImageFileId']) {
$this
->set('sourceImageFile', File::load($cached_data['imageData']['sourceImageFileId']));
}
$this
->set('gifTransparentColor', $cached_data['imageData']['gifTransparentColor']);
$this
->set('caching', TRUE);
$this
->set('bubbleableMetadata', $cached_data['bubbleableMetadata']);
$this->processed = TRUE;
}
else {
throw new TextimageException("Missing Textimage cache entry {$this->id}");
}
return $this;
}