- Added Kash interfaces
This commit is contained in:
1 parent
aba9a65a3c
commit
5bebe231c7
12 files changed
+77
-34
No files matched your search
+1
-1
@@ -8,7 +8,7 @@ class Application
|
||||
{
|
||||
public string $name;
|
||||
|
||||
public string $piceaContext;
|
||||
public /*string|array*/ $piceaContext;
|
||||
|
||||
public array $piceaExtensions;
|
||||
|
||||
|
||||
@@ -55,6 +55,18 @@ class Composer
|
||||
}
|
||||
}
|
||||
|
||||
public static function postUpdate(Event $event) : void
|
||||
{
|
||||
$event->getIO()->write("post-update script executing ...");
|
||||
|
||||
$path = static::createPath('var/cache/version.cache');
|
||||
|
||||
if ( file_exists($path) ) {
|
||||
$event->getIO()->write("removing cache file version to force a '$path'");
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
|
||||
protected static function readComposerJson(Event $event) : ? array
|
||||
{
|
||||
$path = static::createPath('composer.json');
|
||||
|
||||
+18
-5
@@ -18,6 +18,7 @@ use Psr\Http\Message\ResponseInterface;
|
||||
use TheBugs\Email\MailerInterface;
|
||||
|
||||
use Notes\Cronard\Annotation\Method\Cronard,
|
||||
Notes\Breadcrumb\Annotation\Method\Breadcrumb,
|
||||
Notes\Route\Annotation\Object\Route as RouteParam,
|
||||
Notes\Route\Annotation\Method\Route,
|
||||
Notes\Security\Annotation\Security,
|
||||
@@ -26,11 +27,11 @@ use Notes\Cronard\Annotation\Method\Cronard,
|
||||
|
||||
use function file_get_contents;
|
||||
|
||||
/**
|
||||
* @Security("locked" => true)
|
||||
* @RouteParam("methods" => [ "GET", "POST", "DELETE" ])
|
||||
*/
|
||||
#[\Notes\Security\Attribute\Security(locked: true)]
|
||||
#[\Notes\Route\Attribute\Object\Route(method: [ "GET", "POST", "DELETE" ])]
|
||||
trait ControllerTrait {
|
||||
public ? \Notes\Breadcrumb\Breadcrumb $breadcrumb;
|
||||
|
||||
public ? Session $session;
|
||||
|
||||
public ? Picea\Picea $picea;
|
||||
@@ -149,7 +150,8 @@ trait ControllerTrait {
|
||||
return $this->picea->compiler->getExtensionFromToken('route')->buildRouteUrl($name, $parameters);
|
||||
}
|
||||
|
||||
public function json($data, int $flags = 0) {
|
||||
public function json($data, int $flags = 0) : string
|
||||
{
|
||||
return htmlentities(json_encode($data, $flags), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
@@ -164,4 +166,15 @@ trait ControllerTrait {
|
||||
{
|
||||
return $name ? $this->contextList[$name] : array_values($this->contextList)[0] ?? null;
|
||||
}
|
||||
|
||||
public function isRoute(mixed $name, ServerRequestInterface $request) : bool
|
||||
{
|
||||
foreach((array) $name as $item) {
|
||||
if ( fnmatch($item, $request->getAttribute('lean.route')->name) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -11,9 +11,11 @@ use League\Route\Strategy\ApplicationStrategy;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use Tell\I18n;
|
||||
use Ulmus\Container\AdapterProxy;
|
||||
|
||||
use Ulmus\Ulmus;
|
||||
use Zend\Diactoros\ServerRequestFactory,
|
||||
Zend\HttpHandlerRunner\Emitter\EmitterInterface;
|
||||
|
||||
@@ -127,6 +129,7 @@ class Kernel {
|
||||
protected function serviceContainer() : self
|
||||
{
|
||||
$this->container->has(AdapterProxy::class) and $this->container->get(AdapterProxy::class);
|
||||
$this->container->has('ulmus.caching') and ( Ulmus::$cache = $this->container->get('ulmus.caching') );
|
||||
$this->container->has(Lean::class) and $this->container->get(Lean::class);
|
||||
|
||||
if ($this->container->has(I18n::class)) {
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ class Lean
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPiceaContext() : string
|
||||
public function getPiceaContext() /*: string|array */
|
||||
{
|
||||
foreach(array_reverse($this->applications) as $apps) {
|
||||
if ( $apps->piceaContext ?? null ) {
|
||||
|
||||
+10
-1
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use Notes\Annotation;
|
||||
use Taxus\Taxus;
|
||||
|
||||
use League\Route\RouteGroup,
|
||||
@@ -27,6 +28,8 @@ use function DI\autowire, DI\create;
|
||||
|
||||
class Routing {
|
||||
|
||||
public Annotation $selectedRoute;
|
||||
|
||||
protected Session $session;
|
||||
|
||||
protected Cookie $cookie;
|
||||
@@ -106,7 +109,13 @@ class Routing {
|
||||
$container->get(Picea::class)->globalVariables['route'] = $annotation;
|
||||
}
|
||||
|
||||
return $object->$method($request->withAttribute('lean.route', $annotation), $arguments);
|
||||
$request = $request->withAttribute('lean.route', $annotation);
|
||||
|
||||
$this->session->set("lean.route", $annotation);
|
||||
|
||||
$container->set(ServerRequestInterface::class, $request);
|
||||
|
||||
return $object->$method($request, $arguments);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user