- WIP on Picea's assets
This commit is contained in:
parent
4c0cddd617
commit
bc6880c166
|
@ -37,14 +37,10 @@ return [
|
|||
],
|
||||
|
||||
'asset' => [
|
||||
"public_path" => getenv("PUBLIC_PATH"),
|
||||
'destination_path' => "static",
|
||||
'source' => [
|
||||
[
|
||||
'path' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), "asset", '' ]),
|
||||
'order' => 10
|
||||
]
|
||||
],
|
||||
[
|
||||
'path' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), "asset", '' ]),
|
||||
'order' => 10
|
||||
]
|
||||
],
|
||||
|
||||
'extensions' => [],
|
||||
|
|
|
@ -4,7 +4,10 @@ use function DI\autowire, DI\create, DI\get;
|
|||
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
use Picea\{Asset\Action\InstallActionInterface,
|
||||
use Picea\{
|
||||
Asset,
|
||||
Asset\Action,
|
||||
Asset\Action\InstallActionInterface,
|
||||
Language\LanguageRegistration,
|
||||
Caching\Cache,
|
||||
Caching\Opcache,
|
||||
|
@ -16,7 +19,6 @@ use Picea\{Asset\Action\InstallActionInterface,
|
|||
Method\Request};
|
||||
use Picea\Extension\{ LanguageHandlerInterface, LanguageExtension, TitleExtension, NumberExtension, UrlExtension };
|
||||
use Picea\Ui\{ Method, Ui };
|
||||
use Picea\Asset\{ Asset, Action };
|
||||
|
||||
return [
|
||||
Picea\Picea::class => function($c) {
|
||||
|
@ -29,7 +31,11 @@ return [
|
|||
|
||||
Ui::class => autowire(Ui::class),
|
||||
|
||||
Asset::class => autowire(Asset::class),
|
||||
Asset\Asset::class => autowire(Asset\Asset::class),
|
||||
|
||||
Asset\Config::class => create(Asset\Config::class)->constructor(
|
||||
destination: getenv("PUBLIC_PATH") . DIRECTORY_SEPARATOR . "static"
|
||||
),
|
||||
|
||||
Compiler::class => autowire(Compiler::class),
|
||||
|
||||
|
@ -43,7 +49,7 @@ return [
|
|||
|
||||
LanguageHandlerInterface::class => autowire(\Lean\LanguageHandler::class),
|
||||
|
||||
LanguageRegistration::class => create(\Lean\PiceaDefaultRegistration::class)->constructor(get('picea.extensions'), [], [], get(Ui::class), get(Asset::class)),
|
||||
LanguageRegistration::class => create(\Lean\PiceaDefaultRegistration::class)->constructor(get('picea.extensions'), [], [], get(Ui::class), get(Asset\Asset::class)),
|
||||
|
||||
'picea.extensions' => function(\Psr\Container\ContainerInterface $c) {
|
||||
return array_merge([
|
||||
|
@ -71,8 +77,8 @@ return [
|
|||
return new FileFetcher($c->get(Lean\Lean::class)->getViewPaths());
|
||||
},
|
||||
|
||||
Picea\Asset\FileFetcher::class => function($c) {
|
||||
return new Picea\Asset\FileFetcher($c->get(Lean\Lean::class)->getAssetPaths());
|
||||
Asset\FileFetcher::class => function($c) {
|
||||
return new Asset\FileFetcher($c->get(Lean\Lean::class)->getAssetPaths());
|
||||
},
|
||||
|
||||
Action\Install::class => autowire(Action\Install::class)->constructor(get(Action\InstallActionInterface::class), []),
|
||||
|
|
|
@ -69,6 +69,10 @@ class Composer
|
|||
|
||||
new CacheInvalidator($path, true);
|
||||
}
|
||||
|
||||
if ( file_exists($container = static::createPath('var/cache/di/CompiledContainer.php')) ) {
|
||||
unlink($container);
|
||||
}
|
||||
}
|
||||
|
||||
public static function readComposerLock() : false|array
|
||||
|
|
|
@ -116,6 +116,13 @@ class Kernel {
|
|||
# No proxies yet... $containerBuilder->writeProxiesToFile(true, getenv("CACHE_PATH") . "/di/");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$compiled = getenv("CACHE_PATH") . "/di/CompiledContainer.php";
|
||||
|
||||
if ( file_exists($compiled) ) {
|
||||
unlink($compiled);
|
||||
}
|
||||
}
|
||||
|
||||
# $containerBuilder->useAnnotations(false);
|
||||
|
||||
|
|
57
src/Lean.php
57
src/Lean.php
|
@ -109,7 +109,7 @@ class Lean
|
|||
|
||||
public function getAssetPaths() : array
|
||||
{
|
||||
$list = array_merge(...array_map(fn($app) => $app->piceaAssets['source'] ?? [], $this->applications));
|
||||
$list = array_merge(...array_map(fn($app) => $app->piceaAssets ?? [], $this->applications));
|
||||
|
||||
uasort($list, fn($i1, $i2) => $i1['order'] <=> $i2['order'] );
|
||||
|
||||
|
@ -162,21 +162,7 @@ class Lean
|
|||
|
||||
foreach(Composer::readComposerLock()['packages'] as $package) {
|
||||
foreach($package['extra']['lean']['autoload']['definitions'] ?? [] as $autoload) {
|
||||
if (is_string($autoload)) {
|
||||
$vendor = getenv('VENDOR_PATH') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3);
|
||||
$file = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload;
|
||||
|
||||
if ( ! file_exists($file) ) {
|
||||
throw new \InvalidArgumentException(sprintf("Given autoload file `%s` from package `%s` was not found or is unreachable", $autoload, $package['name']));
|
||||
}
|
||||
|
||||
$list = array_replace($list, require($file));
|
||||
}
|
||||
else {
|
||||
$func = implode('::', array_merge([ key($autoload) ], $autoload));
|
||||
|
||||
$list = array_replace($list, call_user_func($func));
|
||||
}
|
||||
$list = array_replace($list, static::loadFromPackage($package, $autoload));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,24 +175,33 @@ class Lean
|
|||
|
||||
foreach(Composer::readComposerLock()['packages'] as $package) {
|
||||
foreach($package['extra']['lean']['autoload']['config'] ?? [] as $autoload) {
|
||||
if (is_string($autoload)) {
|
||||
$vendor = getenv('VENDOR_PATH') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3);
|
||||
$file = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload;
|
||||
|
||||
if ( ! file_exists($file) ) {
|
||||
throw new \InvalidArgumentException(sprintf("Given autoload file `%s` from package `%s` was not found or is unreachable", $autoload, $package['name']));
|
||||
}
|
||||
|
||||
$list = array_merge_recursive($list, require($file));
|
||||
}
|
||||
else {
|
||||
$func = implode('::', array_merge([ key($autoload) ], $autoload));
|
||||
|
||||
$list = array_merge_recursive($list, call_user_func($func));
|
||||
}
|
||||
$list = array_merge_recursive($list, static::loadFromPackage($package, $autoload));
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected static function loadFromPackage(array $package, array|string $autoload) : false|array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
if (is_string($autoload)) {
|
||||
$vendor = getenv('VENDOR_DIR') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3);
|
||||
$file = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload;
|
||||
|
||||
if ( ! file_exists($file) ) {
|
||||
throw new \InvalidArgumentException(sprintf("Given autoload file `%s` from package `%s` was not found or is unreachable", $autoload, $package['name']));
|
||||
}
|
||||
|
||||
return require($file);
|
||||
}
|
||||
else {
|
||||
$func = implode('::', array_merge([ key($autoload) ], $autoload));
|
||||
|
||||
return call_user_func($func);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -8,9 +8,6 @@
|
|||
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato|Ubuntu%20Mono">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
|
||||
<link rel="stylesheet" href='{% asset "asset/css/bulma.extension.css" %}'>
|
||||
<link rel="stylesheet" href="https://cdn.eckinox.net/fontawesome/latest/css/fontawesome-all.min.css">
|
||||
|
||||
|
||||
<style>
|
||||
body {background:#272822}
|
||||
|
|
Loading…
Reference in New Issue