diff --git a/meta/definitions/routes.php b/meta/definitions/routes.php index 9bfde7f..bbd2d1f 100644 --- a/meta/definitions/routes.php +++ b/meta/definitions/routes.php @@ -72,7 +72,7 @@ return [ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { - return new Zend\Diactoros\Response\HtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404); + return new Laminas\Diactoros\Response\HtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404); } }; diff --git a/meta/definitions/security.php b/meta/definitions/security.php new file mode 100644 index 0000000..1cc4c09 --- /dev/null +++ b/meta/definitions/security.php @@ -0,0 +1,22 @@ + function ($c) { + return ( new Taxus( $c->get(PermissionGrantInterface::class) ) )->add( + [ 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" ], + ); + }, + + PermissionGrantInterface::class => create(DefaultPermissionGrant::class)->constructor(get(ServerRequestInterface::class), get(Session::class)), +]; diff --git a/meta/definitions/software.php b/meta/definitions/software.php index 0e05207..0b6a091 100644 --- a/meta/definitions/software.php +++ b/meta/definitions/software.php @@ -2,7 +2,7 @@ use function DI\autowire, DI\create, DI\get; -use Zend\Diactoros\Response\HtmlResponse; +use Laminas\Diactoros\Response\HtmlResponse; use TheBugs\JavascriptMiddleware; diff --git a/meta/definitions/template.php b/meta/definitions/template.php index 285ad40..58667fd 100644 --- a/meta/definitions/template.php +++ b/meta/definitions/template.php @@ -2,7 +2,7 @@ use function DI\autowire, DI\create, DI\get; -use Zend\Diactoros\Response\HtmlResponse; +use Laminas\Diactoros\Response\HtmlResponse; use Picea\{ Picea, Caching\Cache, Caching\Opcache, Compiler, Compiler\Context, Compiler\BaseContext, FileFetcher, Language\DefaultRegistrations, Method\Request }; use Picea\Extension\{ LanguageHandler, LanguageExtension, TitleExtension, MoneyExtension, UrlExtension }; diff --git a/src/Composer.php b/src/Composer.php index c5f2fef..30b851b 100644 --- a/src/Composer.php +++ b/src/Composer.php @@ -3,6 +3,7 @@ namespace Lean; use Composer\EventDispatcher\Event; +use Kash\CacheInvalidator; class Composer { @@ -48,6 +49,8 @@ class Composer rmdir($dest); $event->getIO()->write("Installation completed."); + + static::postUpdate($event); } else { $event->getIO()->writeError(sprintf("The user you are running this script with doesn't seem to have a writable permission on directory %s", static::createPath())); @@ -61,9 +64,10 @@ class Composer $path = static::createPath('var/cache/version.cache'); - if ( file_exists($path) ) { - $event->getIO()->write("removing cache file version to force a '$path'"); - unlink($path); + if ( is_writeable(dirname($path)) ) { + $event->getIO()->write("regenerating cache file version to invalidate cache for path '$path'"); + + new CacheInvalidator($path, true); } } diff --git a/src/Routing.php b/src/Routing.php index 1d153d0..cd76d4f 100644 --- a/src/Routing.php +++ b/src/Routing.php @@ -80,17 +80,11 @@ class Routing { $container, $route, $annotation ) : ResponseInterface { - $class = $annotation->class; + $class = $annotation->class; $method = $annotation->classMethod; # $container->set($class, autowire($class)->method($method, $request)); - /*if ( null !== ( $languageAnnotation = $this->language->verify($class) ) ) { - if ( $languageAnnotation->key ) { - # TODO !!! $language - } - }*/ - $object = $container->get($class); # Checking if user needs to be logged