Compare commits
7 Commits
dd20215d6a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9719965abb | |||
| 4ce08f2ae4 | |||
| f6b21d80d4 | |||
| 2d1416ddf9 | |||
| 1bc25e2b70 | |||
| 6d7bab5bfe | |||
| a156637df8 |
@@ -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": {
|
||||
|
||||
12
src/Potter/Template/Engine/AbstractTemplateEngine.php
Normal file
12
src/Potter/Template/Engine/AbstractTemplateEngine.php
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
10
src/Potter/Template/Engine/TemplateEngine.php
Normal file
10
src/Potter/Template/Engine/TemplateEngine.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Potter\Template\Engine;
|
||||
|
||||
final class TemplateEngine extends AbstractTemplateEngine
|
||||
{
|
||||
|
||||
}
|
||||
10
src/Potter/Template/Engine/TemplateEngineInterface.php
Normal file
10
src/Potter/Template/Engine/TemplateEngineInterface.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Potter\Template\Engine;
|
||||
|
||||
interface TemplateEngineInterface
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user