- WIP on cleaning of definitions files
This commit is contained in:
parent
63fde92b68
commit
d9f9c053c3
|
@ -87,6 +87,7 @@
|
|||
"meta/definitions/email.php",
|
||||
"meta/definitions/event.php",
|
||||
"meta/definitions/http.php",
|
||||
"meta/definitions/orm.php",
|
||||
"meta/definitions/language.php",
|
||||
"meta/definitions/routes.php",
|
||||
"meta/definitions/software.php",
|
||||
|
|
|
@ -1,29 +1,37 @@
|
|||
<?php
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Tell\I18n;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Notes\Tell\LanguageHandler;
|
||||
|
||||
return [
|
||||
Tell\I18n::class => create( Tell\I18n::class ) ->constructor(
|
||||
get(Tell\Reader\JsonReader::class),
|
||||
get(Tell\Reader\PhpReader::class),
|
||||
get('tell.fallback') /* getenv("DEBUG") ? create(Tell\PrintMissingKey::class) : get('tell.fallback') */
|
||||
),
|
||||
use function DI\autowire, DI\create, DI\get, DI\add;
|
||||
|
||||
'tell.fallback' => function($c) {
|
||||
$i18n = new Tell\I18n( $c->get(Tell\Reader\JsonReader::class), $c->get(Tell\Reader\PhpReader::class), new Tell\PrintMissingKey() );
|
||||
return [
|
||||
I18n::class => function(ContainerInterface $container) {
|
||||
$i18n = new I18n($container->get(Tell\Reader\JsonReader::class), $container->get(Tell\Reader\PhpReader::class), $container->get('tell.fallback'));
|
||||
$i18n->locale(getenv('DEFAULT_LOCAL'));
|
||||
$i18n->initialize(! getenv("DEBUG"));
|
||||
|
||||
return $i18n;
|
||||
},
|
||||
|
||||
'tell.fallback' => function(ContainerInterface $container) {
|
||||
$i18n = new Tell\I18n( $container->get(Tell\Reader\JsonReader::class), $container->get(Tell\Reader\PhpReader::class), new Tell\PrintMissingKey() );
|
||||
$i18n->locale(getenv('DEFAULT_LOCAL_FALLBACK') ?: "en_US");
|
||||
$i18n->initialize(true);
|
||||
|
||||
return $i18n;
|
||||
},
|
||||
|
||||
Tell\Reader\PhpReader::class => function($c) {
|
||||
return new Tell\Reader\PhpReader($c->get(Lean\Lean::class)->getI18n('php'), false);
|
||||
Tell\Reader\PhpReader::class => function(ContainerInterface $container) {
|
||||
return new Tell\Reader\PhpReader($container->get(Lean\Lean::class)->getI18n('php'), false);
|
||||
},
|
||||
|
||||
Tell\Reader\JsonReader::class => function($c) {
|
||||
return new Tell\Reader\JsonReader($c->get(Lean\Lean::class)->getI18n('json'), true, \JSON_PRETTY_PRINT);
|
||||
Tell\Reader\JsonReader::class => function(ContainerInterface $container) {
|
||||
return new Tell\Reader\JsonReader($container->get(Lean\Lean::class)->getI18n('json'), true, \JSON_PRETTY_PRINT);
|
||||
},
|
||||
|
||||
'lean.autoload' => add([
|
||||
I18n::class,
|
||||
]),
|
||||
];
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
use Ulmus\Container\AdapterProxy;
|
||||
|
||||
return [
|
||||
'lean.autoload' => add([
|
||||
AdapterProxy::class,
|
||||
]),
|
||||
];
|
|
@ -54,7 +54,7 @@ return [
|
|||
# PostRequestAuthenticationMiddleware::class,
|
||||
],
|
||||
|
||||
'routes.list' => function($c) {
|
||||
Lean\Routing\RouteDefinitionInterface::class => function($c) {
|
||||
return function (ContainerInterface $container) {
|
||||
$router = $container->get(Router::class);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
use Tell\I18n;
|
||||
|
||||
use TheBugs\JavascriptMiddleware;
|
||||
|
||||
|
@ -10,6 +10,8 @@ use Storage\Cookie,
|
|||
Storage\Session,
|
||||
Storage\SessionMiddleware;
|
||||
|
||||
use function DI\autowire, DI\create, DI\get, DI\add;
|
||||
|
||||
$dir = dirname(__DIR__, 2);
|
||||
|
||||
return [
|
||||
|
@ -74,6 +76,10 @@ return [
|
|||
],
|
||||
],
|
||||
|
||||
'lean.autoload' => add([
|
||||
Lean::class,
|
||||
]),
|
||||
|
||||
Lean::class => autowire(Lean::class),
|
||||
|
||||
JavascriptMiddleware::class => create(JavascriptMiddleware::class),
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Ulmus\ConnectionAdapter;
|
||||
use Ulmus\{ ConnectionAdapter, Container\AdapterProxy };
|
||||
use Lean\Lean;
|
||||
|
||||
return [
|
||||
'lean:adapter.sqlite' => function($c) {
|
||||
|
|
|
@ -37,8 +37,6 @@ class Kernel {
|
|||
|
||||
public string $projectPath;
|
||||
|
||||
public string $routeDefinitionList = 'routes.list';
|
||||
|
||||
public function __construct(string $projectPath)
|
||||
{
|
||||
$this->projectPath = $projectPath;
|
||||
|
@ -141,15 +139,14 @@ class Kernel {
|
|||
|
||||
protected function serviceContainer() : self
|
||||
{
|
||||
$this->container->has(AdapterProxy::class) and $this->container->get(AdapterProxy::class);
|
||||
$this->container->has('ulmus.caching') and ( Ulmus::$cache = $this->container->get('ulmus.caching') );
|
||||
$this->container->has(Lean::class) and $this->container->get(Lean::class);
|
||||
|
||||
if ($this->container->has(I18n::class)) {
|
||||
$i18n = $this->container->get(I18n::class);
|
||||
$i18n->locale($this->locale);
|
||||
$i18n->initialize(!getenv("DEBUG"));
|
||||
if ($this->container->has('lean.autoload')) {
|
||||
foreach($this->container->get('lean.autoload') as $class) {
|
||||
$this->container->get($class);
|
||||
}
|
||||
}
|
||||
|
||||
# Must be removed from KERNEL !
|
||||
$this->container->has('ulmus.caching') and ( Ulmus::$cache = $this->container->get('ulmus.caching') );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -158,8 +155,7 @@ class Kernel {
|
|||
{
|
||||
ServerRequestFactory::fromGlobals($_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
|
||||
|
||||
// Router
|
||||
$routeFactory = $this->container->get($this->routeDefinitionList);
|
||||
$routeFactory = $this->container->get(Routing\RouteDefinitionInterface::class);
|
||||
|
||||
$router = $routeFactory($this->container);
|
||||
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<?php
|
||||
|
||||
namespace Lean\Routing;
|
||||
|
||||
interface RouteDefinitionInterface {}
|
Loading…
Reference in New Issue