diff --git a/meta/definitions/software.php b/meta/definitions/software.php index c8c4eb9..ddda44b 100644 --- a/meta/definitions/software.php +++ b/meta/definitions/software.php @@ -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' => [], diff --git a/meta/definitions/template.php b/meta/definitions/template.php index 6ed312c..7683ae0 100644 --- a/meta/definitions/template.php +++ b/meta/definitions/template.php @@ -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), []), diff --git a/src/Composer.php b/src/Composer.php index 20083f5..572be9f 100644 --- a/src/Composer.php +++ b/src/Composer.php @@ -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 diff --git a/src/Kernel.php b/src/Kernel.php index 9f4da25..b6784a4 100644 --- a/src/Kernel.php +++ b/src/Kernel.php @@ -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); diff --git a/src/Lean.php b/src/Lean.php index d124adb..63a00d8 100644 --- a/src/Lean.php +++ b/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; + } } \ No newline at end of file diff --git a/view/lean/layout/error.phtml b/view/lean/layout/error.phtml index 1ba919b..f73f918 100644 --- a/view/lean/layout/error.phtml +++ b/view/lean/layout/error.phtml @@ -8,9 +8,6 @@ - - -