GFPDF\Plugins\PdfForGravityView\Pdf\Maps\ImageStore
Scratch space for the Static Map PNGs of the document being rendered right now.
Google's Maps Platform terms don't permit storing or caching Static Maps imagery; the Geo print
guidelines do permit it inside a printed document. So the tiles live exactly as long as it takes mPDF
to embed them: written on the way in, deleted on the way out, never read by a later request. What
spares the repeat visitor is Pdf\Cache, which stores the finished PDF.
Since: 2.0
Source: src/Pdf/Maps/ImageStore.php:44
Details
- Kind:
class - Namespace:
GFPDF\Plugins\PdfForGravityView\Pdf\Maps
Properties
| Property | Type | Description |
|---|---|---|
$data | Helper_Data | |
$token | string | null | The request's own directory under SUBDIR_NAME, once one has been named. |
Methods
| Method | Description |
|---|---|
__construct() | |
init() | Called by Helper_Abstract_Addon::init() when the store is registered. |
get() | |
put() | Write the PNG body to the render's scratch directory. |
purge() | Delete this render's PNGs and the directory holding them. |
dir() | This render's scratch directory. Named on first use and stable until {@see purge()}, so the delete |
Method Reference
__construct()
public function __construct( Helper_Data $data )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$data | Helper_Data |
Since: 2.0
Source: src/Pdf/Maps/ImageStore.php:59
init()
public function init(): void
Called by Helper_Abstract_Addon::init() when the store is registered.
Returns
void
Since: 2.0
Source: src/Pdf/Maps/ImageStore.php:70
get()
public function get( string $hash )
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$hash | string | sha256 of the canonical inputs. |
Returns
string|false— Local path to the PNG, or false when this render hasn't fetched it.
Since: 2.0
Source: src/Pdf/Maps/ImageStore.php:81
put()
public function put( string $hash, string $body )
Write the PNG body to the render's scratch directory.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$hash | string | ||
$body | string | Raw PNG bytes. |
Returns
string|false— Local path on success, false on failure.
Since: 2.0
Source: src/Pdf/Maps/ImageStore.php:97
purge()
public function purge(): int
Delete this render's PNGs and the directory holding them.
Hooked onto gfpdf_gv_render_complete, which \GFPDF\Plugins\PdfForGravityView\Pdf\Renderer
fires once the document is written — so the tiles go the moment mPDF has finished with them, and a
request rendering several PDFs (notifications do) doesn't hold the first one's tiles until the last.
Safe to call again; it fires per render and the test suite calls it directly.
Returns
int— Files removed.
Since: 2.0
Source: src/Pdf/Maps/ImageStore.php:130
dir()
public function dir(): string
This render's scratch directory. Named on first use and stable until {@see purge()}, so the delete
removes what this render wrote and nothing a concurrent one is still using.
Returns
string
Since: 2.0
Source: src/Pdf/Maps/ImageStore.php:159