- WIP on Picea's Asset.

This commit is contained in:
Dave M. 2023-10-17 20:12:39 -04:00
parent d5de5e665b
commit 043fb90f8d
7 changed files with 17 additions and 32 deletions

View File

@ -10,7 +10,7 @@ use function DI\autowire, DI\create, DI\get;
use Laminas\Diactoros\Response\HtmlResponse; use Laminas\Diactoros\Response\HtmlResponse;
use Picea\{ Picea, Caching\Cache, Caching\Opcache, Compiler, Compiler\Context, Compiler\BaseContext, FileFetcher, Language\DefaultRegistrations, Method\Request }; use Picea\{ Picea, Caching\Cache, Caching\Opcache, Compiler, Compiler\Context, Compiler\BaseContext, FileFetcher, Language\DefaultRegistrations, Method\Request };
use Picea\Extension\{ LanguageHandler, LanguageExtension, TitleExtension, NumberExtension, UrlExtension }; use Picea\Extension\{ LanguageHandlerInterface, LanguageExtension, TitleExtension, NumberExtension, UrlExtension };
use Picea\Ui\{ Method, Ui }; use Picea\Ui\{ Method, Ui };
return [ return [
@ -49,10 +49,10 @@ return [
Method\Pagination::class => autowire(Method\Pagination::class), Method\Pagination::class => autowire(Method\Pagination::class),
LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandler::class)), LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandlerInterface::class)),
LanguageHandler::class => function($c) { LanguageHandlerInterface::class => function($c) {
return new class( $c->get(Tell\I18n::class) ) implements LanguageHandler { return new class( $c->get(Tell\I18n::class) ) implements LanguageHandlerInterface {
public Tell\I18n $tell; public Tell\I18n $tell;
public function __construct(Tell\I18n $tell) { public function __construct(Tell\I18n $tell) {

View File

@ -25,11 +25,10 @@ class Compiler
public array $extensionList = []; public array $extensionList = [];
public ? LanguageRegistration $languageRegistration; public function __construct(
public LanguageRegistration $languageRegistration
public function __construct(?LanguageRegistration $languageRegistration = null) )
{ {
$this->languageRegistration = $languageRegistration;
$this->languageRegistration->registerAll($this); $this->languageRegistration->registerAll($this);
} }
@ -158,7 +157,7 @@ class Compiler
return $this->extensionList[$tokenName]; return $this->extensionList[$tokenName];
} }
public function exportFunctions() : void public function exportFunctions() : void
{ {
static $caching = []; static $caching = [];

View File

@ -11,9 +11,9 @@ class LanguageExtension implements Extension, FunctionExtension {
public string $currentLanguage = ""; public string $currentLanguage = "";
protected LanguageHandler $languageHandler; protected LanguageHandlerInterface $languageHandler;
public function __construct(LanguageHandler $handler) { public function __construct(LanguageHandlerInterface $handler) {
$this->languageHandler = $handler; $this->languageHandler = $handler;
} }

View File

@ -2,7 +2,7 @@
namespace Picea\Extension; namespace Picea\Extension;
interface LanguageHandler interface LanguageHandlerInterface
{ {
public function languageFromKey(string $key, array $variables = []); #: array|string; public function languageFromKey(string $key, array $variables = []); #: array|string;
} }

View File

@ -43,13 +43,6 @@ PATTERN;
$this->assetToken = $assetToken; $this->assetToken = $assetToken;
$this->appUrl = $appUrl; $this->appUrl = $appUrl;
$this->forceSSL = $forceSSL; $this->forceSSL = $forceSSL;
$this->eventRegister(new class() implements BuildAssetUrl {
public function execute(string $uri, array $parameters = [], bool $appendVersion = true) : mixed
{
}
});
} }
public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string public function parse(\Picea\Compiler\Context &$context, ?string $arguments, string $token, array $options = []) : string

View File

@ -6,18 +6,11 @@ use Picea\Compiler;
class DefaultRegistrations implements LanguageRegistration class DefaultRegistrations implements LanguageRegistration
{ {
protected array $extensions; public function __construct(
protected array $extensions,
protected array $syntaxes; protected array $syntaxes,
protected array $controlStructures,
protected array $controlStructures; ) { }
public function __construct(array $extensions = [], array $syntaxes = [], array $controlStructure = [])
{
$this->extensions = $extensions;
$this->syntaxes = $syntaxes;
$this->controlStructures = $controlStructure;
}
public function registerAll(Compiler $compiler) : void public function registerAll(Compiler $compiler) : void
{ {

View File

@ -43,7 +43,7 @@ class Picea implements LanguageRegistration
){ ){
$this->cache = $cache ?? new Caching\Memory(""); $this->cache = $cache ?? new Caching\Memory("");
$this->context = $context ?? new Compiler\BaseContext(); $this->context = $context ?? new Compiler\BaseContext();
$this->languageRegistration = $languageRegistration ?? new Language\DefaultRegistrations(); $this->languageRegistration = $languageRegistration ?? new Language\DefaultRegistrations([], [], []);
$this->builderTemplatePath = $builderTemplatePath ?? dirname(__FILE__) . static::DEFAULT_BUILDER_TEMPLATE; $this->builderTemplatePath = $builderTemplatePath ?? dirname(__FILE__) . static::DEFAULT_BUILDER_TEMPLATE;
$this->compiler = $compiler ?? $this->instanciateCompiler(); $this->compiler = $compiler ?? $this->instanciateCompiler();
$this->fileFetcher = $fileFetcher ?? $this->instanciateFileFetcher(); $this->fileFetcher = $fileFetcher ?? $this->instanciateFileFetcher();