Compare commits

..

7 Commits

Author SHA1 Message Date
9719965abb Create TemplateEngineAwareTrait 2025-10-25 15:36:45 -04:00
4ce08f2ae4 Create TemplateEngineAwareInterface 2025-10-25 15:36:26 -04:00
f6b21d80d4 Require potter/aware 2025-10-25 15:31:36 -04:00
2d1416ddf9 Implement league/plates Engine 2025-10-25 15:24:24 -04:00
1bc25e2b70 Create TemplateEngine 2025-10-25 15:22:29 -04:00
6d7bab5bfe Create AbstractTemplateEngine 2025-10-25 15:22:19 -04:00
a156637df8 Create TemplateEngineInterface 2025-10-25 15:22:10 -04:00
6 changed files with 106 additions and 1 deletions

View File

@@ -2,7 +2,9 @@
"name": "potter/template",
"type": "library",
"require": {
"php": "^8.4"
"php": "^8.4",
"league/plates": "v3.x-dev",
"potter/aware": "dev-main"
},
"license": "MIT",
"autoload": {

View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
namespace Potter\Template\Engine;
use \League\Plates\Engine;
abstract class AbstractTemplateEngine extends Engine implements TemplateEngineInterface
{
}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
namespace Potter\Template\Engine\Aware;
use \Potter\Aware\AwareInterface;
use \Potter\Template\Engine\TemplateEngineInterface;
interface TemplateEngineAwareInterface extends AwareInterface
{
public function getTemplateEngine(): TemplateEngineInterface;
public function hasTemplateEngine(): bool;
public function withTemplateEngine(): self;
public function withoutTemplateEngine(): self;
}

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
namespace Potter\Template\Engine\Aware;
use \Potter\Aware\AwareInterface;
use \Potter\Template\Engine\TemplateEngineInterface;
trait TemplateEngineAwareTrait
{
private const string TEMPLATE_ENGINE = 'templateEngine';
abstract public function get(string $key): mixed;
final public function getTemplateEngine(): TemplateEngineInterface
{
return $this->get(self::TEMPLATE_ENGINE);
}
abstract public function has(string $key): bool;
final public function hasTemplateEngine(): bool
{
return $this->has(self::TEMPLATE_ENGINE);
}
abstract protected function set(string $key, mixed $value): mixed;
final public function setTemplateEngine(TemplateEngineInterface $templateEngine): TemplateEngineInterface
{
return $this->set(self::TEMPLATE_ENGINE, $templateEngine);
}
abstract protected function unset(string $key): void;
final public function unsetTemplateEngine(): void
{
$this->unset(self::TEMPLATE_ENGINE);
}
abstract public function with(string $key, mixed $value): AwareInterface;
final public function withTemplateEngine(TemplateEngineInterface $templateEngine): TemplateEngineAwareInterface
{
return $this->with(self::TEMPLATE_ENGINE, $templateEngine);
}
abstract public function without(string $key): AwareInterface;
final public function withoutTemplateEngine(): TemplateEngineAwareInterface
{
return $this->without(self::TEMPLATE_ENGINE);
}
}

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Potter\Template\Engine;
final class TemplateEngine extends AbstractTemplateEngine
{
}

View File

@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
namespace Potter\Template\Engine;
interface TemplateEngineInterface
{
}