diff --git a/composer.json b/composer.json index 83fe2ea..052defe 100644 --- a/composer.json +++ b/composer.json @@ -16,5 +16,14 @@ }, "require": { "psr/http-message": "^1.0" + }, + "extra": { + "lean": { + "autoload": { + "definitions": [ + "meta/definitions.php" + ] + } + } } -} +} \ No newline at end of file diff --git a/meta/definitions.php b/meta/definitions.php new file mode 100644 index 0000000..a04dfd5 --- /dev/null +++ b/meta/definitions.php @@ -0,0 +1,61 @@ + 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()); + }, + + Ui::class => autowire(Ui::class), + + 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()); + }, +]; \ No newline at end of file