- Update `dynamicimages_asset` constructor to prepend working directory to paths. - Add helper methods (`getPath`, `getWidth`, `getHeight`) to `dynamicimages_asset`. - Extend `dynamicimages_image_t` trait with debugging and path configuration utilities. - Refactor asset path handling in `machine_1` with constants for image files. - Load `dynamicimages` interfaces, traits, classes, helpers, and configurations in `index.php`.
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace dynamicimages\traits;
|
|
|
|
use dynamicimages\classes\dynamicimages_asset;
|
|
use dynamicimages\interfaces\dynamicimages_image_i;
|
|
|
|
trait dynamicimages_image_t
|
|
{
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function setAssets(array $assets): dynamicimages_image_i
|
|
{
|
|
$this->assets = $assets;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getAssets(): array
|
|
{
|
|
return $this->assets;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function addAsset(dynamicimages_asset $asset): dynamicimages_image_i
|
|
{
|
|
$this->assets[] = $asset;
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* Debug
|
|
*/
|
|
public function debugAssets(): void
|
|
{
|
|
echo 'Assets count: ' . count($this->assets) . PHP_EOL;
|
|
foreach ($this->assets as $asset) {
|
|
echo 'Asset path: ' . $asset->getPath() . ' - (Width: ' . $asset->getWidth() . ', Height: ' . $asset->getHeight() . ')' . PHP_EOL;
|
|
}
|
|
}
|
|
|
|
public function getAssetPath(string $asset_name): string
|
|
{
|
|
return $this->module_asset_path . $asset_name;
|
|
}
|
|
|
|
public function setAssetPath(string $asset_path): dynamicimages_image_i
|
|
{
|
|
$this->module_asset_path = $asset_path;
|
|
return $this;
|
|
}
|
|
} |