Compare commits
10
Commits
picea-asset
..
v2.x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
200b58bdf5 | ||
|
|
5e54407f74 | ||
|
|
b856743741 | ||
|
|
10fb17c7c3 | ||
|
|
8b6dd85fd5 | ||
|
|
8c7a4d730b | ||
|
|
ed0eb8225b | ||
|
|
0e655fd387 | ||
|
|
ce43abb954 | ||
|
|
5aa70dfd17 |
No files matched your search
+10
-1
@@ -16,5 +16,14 @@
|
||||
},
|
||||
"require": {
|
||||
"psr/http-message": "^1.0"
|
||||
},
|
||||
"extra": {
|
||||
"lean": {
|
||||
"autoload": {
|
||||
"definitions": [
|
||||
"meta/definitions.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Picea\{
|
||||
Caching\Cache,
|
||||
Caching\Opcache,
|
||||
Compiler,
|
||||
Compiler\Context,
|
||||
Compiler\BaseContext,
|
||||
FileFetcher,
|
||||
Method\Request
|
||||
};
|
||||
|
||||
use Picea\Extension\{ LanguageHandlerInterface, LanguageExtension, TitleExtension, NumberExtension, UrlExtension };
|
||||
|
||||
return [
|
||||
Picea\Picea::class => function($c) {
|
||||
return new Picea\Picea($c->get(Context::class), $c->get(Cache::class), $c->get(Compiler::class), null, $c->get(FileFetcher::class), null, getenv("DEBUG"));
|
||||
},
|
||||
|
||||
Context::class => function($c) {
|
||||
return new BaseContext($c->get(Lean\Lean::class)->getPiceaContext());
|
||||
},
|
||||
|
||||
Compiler::class => autowire(Compiler::class),
|
||||
|
||||
Request::class => autowire(Request::class),
|
||||
|
||||
LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandlerInterface::class)),
|
||||
|
||||
# LanguageHandlerInterface::class => autowire(\Lean\LanguageHandler::class),
|
||||
|
||||
# LanguageRegistration::class => create(\Lean\PiceaDefaultRegistration::class)->constructor(get('picea.extensions'), [], [], get(Ui::class), null),
|
||||
|
||||
'picea.extensions' => function(\Psr\Container\ContainerInterface $c) {
|
||||
return array_merge([
|
||||
$c->get(LanguageExtension::class),
|
||||
$c->get(TitleExtension::class),
|
||||
$c->get(NumberExtension::class),
|
||||
$c->get(UrlExtension::class),
|
||||
$c->get(Request::class),
|
||||
], class_exists(\Taxus\Picea\Extension::class) ? [ $c->get(\Taxus\Picea\Extension::class) ] : [],
|
||||
array_map(fn($class) => $c->get($class), $c->get(Lean\Lean::class)->getPiceaExtensions())
|
||||
);
|
||||
},
|
||||
|
||||
TitleExtension::class => autowire(TitleExtension::class),
|
||||
|
||||
NumberExtension::class => autowire(NumberExtension::class),
|
||||
|
||||
UrlExtension::class => create(UrlExtension::class)->constructor(getenv("URL_BASE"), get('git.commit'), explode(',', getenv('APP_URL')), (bool) getenv('FORCE_SSL')),
|
||||
|
||||
Cache::class => create(Opcache::class)->constructor(getenv("CACHE_PATH"), get(Context::class)),
|
||||
|
||||
FileFetcher::class => function($c) {
|
||||
return new FileFetcher($c->get(Lean\Lean::class)->getViewPaths());
|
||||
},
|
||||
];
|
||||
@@ -4,7 +4,7 @@ namespace Picea\Compiler;
|
||||
|
||||
class BaseContext extends Context {
|
||||
|
||||
public function __construct(?string $defaultNamespace = null) {
|
||||
public function __construct(array|string|null $defaultNamespace = null) {
|
||||
if ( $defaultNamespace !== null ) {
|
||||
$this->namespace = $defaultNamespace;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Picea\Compiler;
|
||||
|
||||
abstract class Context {
|
||||
|
||||
public string $namespace = "";
|
||||
public string|array $namespace = "";
|
||||
|
||||
public string $extendFrom = "";
|
||||
|
||||
|
||||
@@ -33,6 +33,8 @@ class SectionToken implements ControlStructure {
|
||||
throw new \RuntimeException("A section closing tag {% endsection %} was found without an opening {% section %} tag");
|
||||
}
|
||||
|
||||
$this->action = PrintActionEnum::default;
|
||||
|
||||
return $this->printEndSection($context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Picea\Event\Extension;
|
||||
|
||||
interface BuildAssetUrl
|
||||
{
|
||||
public function execute(string $uri, array $parameters = [], bool $appendVersion = true) : mixed;
|
||||
}
|
||||
@@ -15,6 +15,7 @@ class NumberExtension implements Extension, FunctionExtension {
|
||||
public string $title = "",
|
||||
) {
|
||||
$this->locale = explode('.', \Locale::getDefault())[0];
|
||||
$this->formatter = new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY);
|
||||
}
|
||||
|
||||
public function exportFunctions(): array
|
||||
@@ -55,8 +56,6 @@ class NumberExtension implements Extension, FunctionExtension {
|
||||
|
||||
public function money(float $money, ? string $currency = null) /* : string|false */
|
||||
{
|
||||
$this->formatter ??= new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY);
|
||||
|
||||
$this->formatter->setTextAttribute(\NumberFormatter::CURRENCY_CODE, 'CAD');
|
||||
|
||||
$this->formatter->setPattern( str_replace('¤#','¤ #', $this->formatter->getPattern() ) );
|
||||
|
||||
@@ -8,7 +8,7 @@ class PrintExtension implements Extension {
|
||||
|
||||
public array $token = [ "echo", "print", "printf", "no_html" ];
|
||||
|
||||
public int $flag = \ENT_QUOTES;
|
||||
public int $flag = \ENT_QUOTES | \ENT_DISALLOWED | \ENT_SUBSTITUTE;
|
||||
|
||||
public string $encoding;
|
||||
|
||||
|
||||
@@ -2,15 +2,10 @@
|
||||
|
||||
namespace Picea\Extension;
|
||||
|
||||
use Notes\Route\Attribute\Object\Route;
|
||||
use Picea\EventTrait;
|
||||
use Picea\Compiler\Context;
|
||||
|
||||
use Picea\Event\Extension\{ UrlBuildAssetEvent, UrlBuildUrlEvent, UrlBuildRouteEvent, UrlRegisterRouteEvent };
|
||||
|
||||
class UrlExtension implements Extension, FunctionExtension {
|
||||
use \Picea\EventTrait;
|
||||
|
||||
use EventTrait;
|
||||
|
||||
public const URLIZE_PATTERN_URL = <<<PATTERN
|
||||
@@ -68,7 +63,7 @@ PATTERN;
|
||||
return "<?php echo \$picea->compiler->getExtensionFromToken('$token')->slug($arguments) ?>";
|
||||
}
|
||||
|
||||
throw new \ParseExtensionException("Unknown token given $token in UrlExtension.");
|
||||
throw new \Exception("Unknown token given $token in UrlExtension.");
|
||||
}
|
||||
|
||||
public function exportFunctions(): array
|
||||
|
||||
@@ -180,6 +180,7 @@ class Picea implements LanguageRegistration
|
||||
{
|
||||
if ( $this->debug || ! $this->cache->compiled( $context->cacheFilename() ) ) {
|
||||
$context = $this->compileContext($context);
|
||||
|
||||
$this->cache->save($context);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user