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