- WIP on leaning lean a bit
This commit is contained in:
parent
4f648b47bd
commit
f3c4cbd95a
|
@ -140,13 +140,10 @@
|
||||||
"definitions" : [
|
"definitions" : [
|
||||||
"meta/definitions/software.php",
|
"meta/definitions/software.php",
|
||||||
"meta/definitions/authorize.php",
|
"meta/definitions/authorize.php",
|
||||||
"meta/definitions/cli.php",
|
|
||||||
"meta/definitions/cronard.php",
|
|
||||||
"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/language.php",
|
"meta/definitions/language.php",
|
||||||
"meta/definitions/negundo.php",
|
|
||||||
"meta/definitions/routes.php",
|
"meta/definitions/routes.php",
|
||||||
"meta/definitions/software.php",
|
"meta/definitions/software.php",
|
||||||
"meta/definitions/storage.php",
|
"meta/definitions/storage.php",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
return [
|
return [
|
||||||
'ulmus' => [
|
'ulmus' => [
|
||||||
'connections' => [
|
'connections' => [
|
||||||
'sqlite' => [
|
'lean' => [
|
||||||
'adapter' => 'SQLite',
|
'adapter' => 'SQLite',
|
||||||
'path' => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . "var/lean.sqlite3",
|
'path' => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . "var/lean.sqlite3",
|
||||||
'pragma_begin' => "journal_mode=WAL",
|
'pragma_begin' => "journal_mode=WAL",
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use function DI\autowire, DI\create, DI\get;
|
|
||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
|
|
||||||
use Mcnd\CLI\CliMiddleware;
|
|
||||||
|
|
||||||
use Notes\CLI\CommandFetcher;
|
|
||||||
|
|
||||||
use Lean\{ Factory, Lean };
|
|
||||||
|
|
||||||
return [
|
|
||||||
CommandFetcher::class => function($c) {
|
|
||||||
$fetcher = new CommandFetcher(null, null, $c->get('cli.caching'));
|
|
||||||
|
|
||||||
$fetcher->setFolderList(array_map(function($item) {
|
|
||||||
return $item;
|
|
||||||
}, $c->get(Lean::class)->getCli()));
|
|
||||||
|
|
||||||
return $fetcher;
|
|
||||||
},
|
|
||||||
|
|
||||||
CliMiddleware::class => function($c) {
|
|
||||||
return new CliMiddleware($c, $c->get('cli.response:default'), $c->get(CommandFetcher::class));
|
|
||||||
},
|
|
||||||
|
|
||||||
'cli.response:default' => function($c) {
|
|
||||||
return function() {
|
|
||||||
return Factory\HttpFactory::createTextResponse("This is the default response from CLI middleware which indicates that no command were registered for this application.\n");
|
|
||||||
};
|
|
||||||
},
|
|
||||||
];
|
|
|
@ -1,30 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use function DI\autowire, DI\create, DI\get;
|
|
||||||
|
|
||||||
use Cronard\CronardMiddleware,
|
|
||||||
Notes\Cronard\TaskFetcher;
|
|
||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
|
||||||
|
|
||||||
use Lean\{ Factory, Lean };
|
|
||||||
|
|
||||||
return [
|
|
||||||
CronardMiddleware::class => function($c) {
|
|
||||||
$cronardMiddleware = new CronardMiddleware($c, getenv('CRON_KEY'), function() : ResponseInterface {
|
|
||||||
return Factory\HttpFactory::createHtmlResponse(sprintf("%s - cron task begin...", date('Y-m-d H:i:s')));
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return $cronardMiddleware->fromFile(getenv("META_PATH")."/crontab.php")->fromAnnotations($c->get(TaskFetcher::class));
|
|
||||||
},
|
|
||||||
|
|
||||||
TaskFetcher::class => function($c) {
|
|
||||||
$fetcher = new TaskFetcher(null, null, $c->get('cronard.caching'));
|
|
||||||
|
|
||||||
$fetcher->setFolderList(array_map(function($item) {
|
|
||||||
return $item;
|
|
||||||
}, $c->get(Lean::class)->getCronard()));
|
|
||||||
|
|
||||||
return $fetcher;
|
|
||||||
},
|
|
||||||
];
|
|
|
@ -19,7 +19,6 @@ return [
|
||||||
return $i18n;
|
return $i18n;
|
||||||
},
|
},
|
||||||
|
|
||||||
# TODO -- accept folders from Lean Apps
|
|
||||||
Tell\Reader\PhpReader::class => function($c) {
|
Tell\Reader\PhpReader::class => function($c) {
|
||||||
return new Tell\Reader\PhpReader($c->get(Lean\Lean::class)->getI18n('php'), false);
|
return new Tell\Reader\PhpReader($c->get(Lean\Lean::class)->getI18n('php'), false);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use function DI\autowire, DI\create, DI\get;
|
|
||||||
|
|
||||||
use Negundo\Client\{ SoftwareConfig, Dump, Task, NegundoMiddleware };
|
|
||||||
|
|
||||||
return [
|
|
||||||
SoftwareConfig::class => create(SoftwareConfig::class)->constructor(getenv('NEGUNDO_HASH'), getenv('NEGUNDO_SERVER')),
|
|
||||||
NegundoMiddleware::class => autowire(NegundoMiddleware::class),
|
|
||||||
Dump::class => autowire(Dump::class),
|
|
||||||
Task::class => autowire(Task::class),
|
|
||||||
];
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Taxus\Privilege;
|
|
||||||
use function DI\autowire, DI\create, DI\get;
|
use function DI\autowire, DI\create, DI\get;
|
||||||
|
|
||||||
use TheBugs\JavascriptMiddleware;
|
use TheBugs\JavascriptMiddleware;
|
||||||
|
@ -66,12 +65,7 @@ return [
|
||||||
|
|
||||||
'cronard' => [],
|
'cronard' => [],
|
||||||
|
|
||||||
'taxus' => [
|
'taxus' => [],
|
||||||
[ new Privilege("dev", "Is a developper of this application."), "is_dev" ],
|
|
||||||
[ new Privilege("admin", "Can manage mostly everything from this application."), "is_admin" ],
|
|
||||||
[ new Privilege("user", "Is an authenticated user."), "is_user" ],
|
|
||||||
[ new Privilege("anonymous", "Is an anonymous (unauthenticated) user."), "is_anonymous" ],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
|
|
||||||
Lean::class => autowire(Lean::class),
|
Lean::class => autowire(Lean::class),
|
||||||
|
|
|
@ -2,68 +2,13 @@
|
||||||
|
|
||||||
use function DI\autowire, DI\create, DI\get;
|
use function DI\autowire, DI\create, DI\get;
|
||||||
|
|
||||||
use Picea\{
|
use Picea\{ Language\LanguageRegistration, };
|
||||||
Language\LanguageRegistration,
|
|
||||||
Caching\Cache,
|
|
||||||
Caching\Opcache,
|
|
||||||
Compiler,
|
|
||||||
Compiler\Context,
|
|
||||||
Compiler\BaseContext,
|
|
||||||
FileFetcher,
|
|
||||||
Method\Request};
|
|
||||||
|
|
||||||
use Picea\Extension\{ LanguageHandlerInterface, LanguageExtension, TitleExtension, NumberExtension, UrlExtension };
|
use Picea\Extension\{ LanguageHandlerInterface, };
|
||||||
|
|
||||||
use Picea\Ui\{ Method, Ui };
|
use Picea\Ui\{ Ui };
|
||||||
|
|
||||||
return [
|
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());
|
|
||||||
},
|
|
||||||
|
|
||||||
Ui::class => autowire(Ui::class),
|
|
||||||
|
|
||||||
Compiler::class => autowire(Compiler::class),
|
|
||||||
|
|
||||||
Request::class => autowire(Request::class),
|
|
||||||
|
|
||||||
Method\Form::class => autowire(Method\Form::class),
|
|
||||||
|
|
||||||
Method\Pagination::class => autowire(Method\Pagination::class),
|
|
||||||
|
|
||||||
LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandlerInterface::class)),
|
|
||||||
|
|
||||||
LanguageHandlerInterface::class => autowire(\Lean\LanguageHandler::class),
|
LanguageHandlerInterface::class => autowire(\Lean\LanguageHandler::class),
|
||||||
|
|
||||||
LanguageRegistration::class => create(\Lean\PiceaDefaultRegistration::class)->constructor(get('picea.extensions'), [], [], get(Ui::class), null),
|
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(Method\Form::class),
|
|
||||||
$c->get(Method\Pagination::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());
|
|
||||||
},
|
|
||||||
];
|
];
|
|
@ -1,12 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use Taxus\Privilege;
|
||||||
|
|
||||||
use function DI\autowire, DI\create, DI\get;
|
use function DI\autowire, DI\create, DI\get;
|
||||||
|
|
||||||
$dir = getenv("META_PATH") . "/definitions";
|
$dir = getenv("META_PATH") . "/definitions";
|
||||||
|
|
||||||
return array_merge(
|
return array_merge(
|
||||||
Lean\Lean::definitions(),
|
|
||||||
|
|
||||||
Lean\Lean::autoloadDefinitionsFromComposerExtra(),
|
Lean\Lean::autoloadDefinitionsFromComposerExtra(),
|
||||||
|
|
||||||
[
|
[
|
||||||
|
@ -15,7 +15,6 @@ return array_merge(
|
||||||
'context' => "%ESCAPED_NAMESPACE%\\View",
|
'context' => "%ESCAPED_NAMESPACE%\\View",
|
||||||
'asset' => [],
|
'asset' => [],
|
||||||
'extensions' => [],
|
'extensions' => [],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'ulmus' => [
|
'ulmus' => [
|
||||||
|
@ -37,6 +36,13 @@ return array_merge(
|
||||||
'cli' => [
|
'cli' => [
|
||||||
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]),
|
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'taxus' => [
|
||||||
|
[ new Privilege("dev", "Is a developper of this application."), "is_dev" ],
|
||||||
|
[ new Privilege("admin", "Can manage mostly everything from this application."), "is_admin" ],
|
||||||
|
[ new Privilege("user", "Is an authenticated user."), "is_user" ],
|
||||||
|
[ new Privilege("anonymous", "Is an anonymous (unauthenticated) user."), "is_anonymous" ],
|
||||||
|
]
|
||||||
],
|
],
|
||||||
|
|
||||||
'app.middlewares' => [],
|
'app.middlewares' => [],
|
||||||
|
|
|
@ -11,10 +11,7 @@ use function DI\autowire, DI\create, DI\get;
|
||||||
return [
|
return [
|
||||||
Taxus::class => function ($c) {
|
Taxus::class => function ($c) {
|
||||||
return ( new Taxus( $c->get(PermissionGrantInterface::class) ) )->add(
|
return ( new Taxus( $c->get(PermissionGrantInterface::class) ) )->add(
|
||||||
[ new Privilege("dev", "Is a developper of this application."), "is_dev" ],
|
$c->get(Lean\Lean::class)->getTaxusPrivileges()
|
||||||
[ new Privilege("admin", "Can manage mostly everything from this application."), "is_admin" ],
|
|
||||||
[ new Privilege("user", "Is an authenticated user."), "is_user" ],
|
|
||||||
[ new Privilege("anonymous", "Is an anonymous (unauthenticated) user."), "is_anonymous" ],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ return [
|
||||||
|
|
||||||
AdapterProxy::class => function (ContainerInterface $c) {
|
AdapterProxy::class => function (ContainerInterface $c) {
|
||||||
return new AdapterProxy(
|
return new AdapterProxy(
|
||||||
|
$c->get('lean:adapter.sqlite'),
|
||||||
$c->get(ConnectionAdapter::class)
|
$c->get(ConnectionAdapter::class)
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,6 +28,8 @@ class Application
|
||||||
|
|
||||||
public array $tellPhp;
|
public array $tellPhp;
|
||||||
|
|
||||||
|
public array $taxus;
|
||||||
|
|
||||||
public array $data = [];
|
public array $data = [];
|
||||||
|
|
||||||
public function __construct(string $name) {
|
public function __construct(string $name) {
|
||||||
|
@ -38,7 +40,14 @@ class Application
|
||||||
{
|
{
|
||||||
$this->data = array_replace($this->data, $data);
|
$this->data = array_replace($this->data, $data);
|
||||||
|
|
||||||
if (is_array($picea = $data['picea'] ?? false)) {
|
$this->loadData();
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function loadData() : static
|
||||||
|
{
|
||||||
|
if (is_array($picea = $this->data['picea'] ?? false)) {
|
||||||
if ($picea['context'] ?? false ) {
|
if ($picea['context'] ?? false ) {
|
||||||
$this->piceaContext = $picea['context'];
|
$this->piceaContext = $picea['context'];
|
||||||
}
|
}
|
||||||
|
@ -56,13 +65,13 @@ class Application
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($ulmus = $data['ulmus'] ?? false)) {
|
if (is_array($ulmus = $this->data['ulmus'] ?? false)) {
|
||||||
if ($ulmus['entities'] ?? false) {
|
if ($ulmus['entities'] ?? false) {
|
||||||
$this->entities = $ulmus['entities'];
|
$this->entities = $ulmus['entities'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($tell = $data['tell'] ?? false)) {
|
if (is_array($tell = $this->data['tell'] ?? false)) {
|
||||||
if ($tell['json'] ?? false) {
|
if ($tell['json'] ?? false) {
|
||||||
$this->tellJson = $tell['json'];
|
$this->tellJson = $tell['json'];
|
||||||
}
|
}
|
||||||
|
@ -72,20 +81,24 @@ class Application
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($data['routes'] ?? false)) {
|
if (is_array($this->data['routes'] ?? false)) {
|
||||||
$this->routes = $data['routes'];
|
$this->routes = $this->data['routes'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($data['cronard'] ?? false)) {
|
if (is_array($this->data['cronard'] ?? false)) {
|
||||||
$this->cronard = $data['cronard'];
|
$this->cronard = $this->data['cronard'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($data['events'] ?? false)) {
|
if (is_array($this->data['events'] ?? false)) {
|
||||||
$this->events = $data['events'];
|
$this->events = $this->data['events'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($data['cli'] ?? false)) {
|
if (is_array($this->data['cli'] ?? false)) {
|
||||||
$this->cli = $data['cli'];
|
$this->cli = $this->data['cli'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($this->data['taxus'] ?? false)) {
|
||||||
|
$this->taxus = $this->data['taxus'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
18
src/Lean.php
18
src/Lean.php
|
@ -155,26 +155,10 @@ class Lean
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[\Deprecated("Definitions are now loaded automatically from composer extra array.")]
|
||||||
public static function definitions() : array
|
public static function definitions() : array
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
|
|
||||||
$path = dirname(__DIR__) . "/meta/definitions/";
|
|
||||||
|
|
||||||
return array_replace(
|
|
||||||
require($path . "authorize.php"),
|
|
||||||
class_exists(\Mcnd\CLI\CliMiddleware::class) ? require($path . "cli.php") : [],
|
|
||||||
class_exists(\Cronard\CronardMiddleware::class) ? require($path . "cronard.php") : [],
|
|
||||||
require($path . "email.php"),
|
|
||||||
require($path . "event.php"),
|
|
||||||
require($path . "http.php"),
|
|
||||||
require($path . "language.php"),
|
|
||||||
class_exists(\Negundo\Client\NegundoMiddleware::class) ? require($path . "negundo.php") : [],
|
|
||||||
require($path . "routes.php"),
|
|
||||||
require($path . "software.php"),
|
|
||||||
require($path . "storage.php"),
|
|
||||||
class_exists(\Picea\Picea::class) ? require($path . "template.php") : [],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function autoloadDefinitionsFromComposerExtra() : array
|
public static function autoloadDefinitionsFromComposerExtra() : array
|
||||||
|
|
Loading…
Reference in New Issue