Merge branch 'master' of https://git.mcnd.ca/mcndave/lean
This commit is contained in:
		
						commit
						d30e687e21
					
				| @ -11,24 +11,6 @@ use Notes\CLI\CommandFetcher; | ||||
| use Lean\Lean; | ||||
| 
 | ||||
| return [ | ||||
|     /*CronardMiddleware::class => function($c) { | ||||
|         $cronardMiddleware = new CronardMiddleware($c, getenv('CRON_KEY'), function() : ResponseInterface { | ||||
|             return new HtmlResponse(sprintf("%s - cron task begin...", date('Y-m-d H:i:s'))); | ||||
|         }, [], $c->get(TaskFetcher::class)); | ||||
| 
 | ||||
|         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; | ||||
|     },*/ | ||||
| 
 | ||||
|     CommandFetcher::class => function($c) { | ||||
|         $fetcher = new CommandFetcher(null, null, $c->get('cli.caching')); | ||||
| 
 | ||||
|  | ||||
| @ -7,6 +7,7 @@ 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, NumberExtension, UrlExtension }; | ||||
| use Picea\Ui\{ Method, Ui }; | ||||
| use Picea\Asset\Asset; | ||||
| 
 | ||||
| return [ | ||||
|     Picea::class => function($c) { | ||||
| @ -33,6 +34,11 @@ return [ | ||||
|             { | ||||
|                 parent::registerAll($compiler); | ||||
|                 ( new Ui() )->registerFormExtension($compiler); | ||||
| 
 | ||||
|                 if ( class_exists('Picea\\Asset\\Asset') ) { | ||||
|                     ( new Asset() )->registerExtension($compiler); | ||||
| 
 | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|         }); | ||||
|  | ||||
							
								
								
									
										9
									
								
								skeleton/lean
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								skeleton/lean
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,9 @@ | ||||
| #!/bin/php | ||||
| <?php | ||||
| 
 | ||||
| try { | ||||
|     require_once(__DIR__."/src/Kernel.php"); | ||||
| } | ||||
| catch(\Throwable $t) { | ||||
|     echo sprintf("%s [ %s ]" , $t->getMessage(),  var_export($t->getTrace(), true)); | ||||
| } | ||||
| @ -30,6 +30,12 @@ return [ | ||||
|                     'charset' => getenv("DATABASE_CHARSET"), | ||||
|                 ], | ||||
|             ], | ||||
| 
 | ||||
|             #'sqlite' => [
 | ||||
|             #    'adapter'  => getenv("SQLITE_ADAPTER"),
 | ||||
|             #    'path'     => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . getenv("SQLITE_PATH"),
 | ||||
|             #    'pragma'   => explode(',', getenv("SQLITE_PRAGMA")),
 | ||||
|             #],
 | ||||
|         ] | ||||
|     ] | ||||
| ]; | ||||
|  | ||||
| @ -63,6 +63,4 @@ return [ | ||||
| 
 | ||||
|         return $email; | ||||
|     }, | ||||
| 
 | ||||
|     PermissionGrantInterface::class => create(%NAMESPACE%\PrivilegeGrantAccess::class)->constructor(get(ServerRequestInterface::class), get(Session::class)), | ||||
| ]; | ||||
|  | ||||
| @ -18,5 +18,5 @@ return [ | ||||
|         ); | ||||
|     }, | ||||
| 
 | ||||
|     PermissionGrantInterface::class => create(DefaultPermissionGrant::class)->constructor(get(ServerRequestInterface::class), get(Session::class)), | ||||
|     PermissionGrantInterface::class => create(%NAMESPACE%\PrivilegeGrantAccess::class)->constructor(get(ServerRequestInterface::class), get(Session::class)), | ||||
| ]; | ||||
|  | ||||
| @ -14,8 +14,6 @@ return [ | ||||
|         $adapter = new ConnectionAdapter('default', $c->get('config')['ulmus'], true); | ||||
|         $adapter->resolveConfiguration(); | ||||
| 
 | ||||
|         $adapter->connect(); | ||||
| 
 | ||||
|         return $adapter; | ||||
|     }, | ||||
| 
 | ||||
|  | ||||
| @ -4,11 +4,12 @@ namespace %NAMESPACE%\Controller; | ||||
| 
 | ||||
| use Psr\Http\Message\{ServerRequestInterface, ResponseInterface }; | ||||
| 
 | ||||
| use Notes\Route\Attribute\Method\Route; | ||||
| 
 | ||||
| use %NAMESPACE%\{ Lib, Entity, Form, }; | ||||
| 
 | ||||
| use function %NAMESPACE%\View\{ _, lang, url, route, form }; | ||||
| 
 | ||||
| #[Language("%APPKEY%.home")]
 | ||||
| class Home { | ||||
|     use Lib\ControllerTrait; | ||||
| 
 | ||||
|  | ||||
| @ -3,7 +3,7 @@ | ||||
| namespace %NAMESPACE%\Entity; | ||||
| 
 | ||||
| use Ulmus\Entity\Field\Datetime; | ||||
| use Ulmus\{Attribute\Obj\Table; | ||||
| use Ulmus\{Attribute\Obj\Table}; | ||||
| 
 | ||||
| use %NAMESPACE%\Lib; | ||||
| 
 | ||||
|  | ||||
| @ -8,7 +8,8 @@ use Ulmus\User\Entity\User; | ||||
| use Ulmus\User\Lib\Authenticate; | ||||
| use Notes\Route\Attribute\Object\Route; | ||||
| use Notes\Security\Attribute\Security; | ||||
| use %NAMESPACE%\Entity; | ||||
| 
 | ||||
| use %NAMESPACE%\{ Entity, Lib, Form }; | ||||
| 
 | ||||
| use Mcnd\Event\EventManager; | ||||
| 
 | ||||
|  | ||||
| @ -2,11 +2,8 @@ | ||||
| 
 | ||||
| namespace %NAMESPACE%\Middleware; | ||||
| 
 | ||||
| use Psr\Http\Server\MiddlewareInterface; | ||||
| use Psr\Http\Message\ServerRequestInterface; | ||||
| use Psr\Http\Server\RequestHandlerInterface; | ||||
| use Psr\Http\Message\ResponseInterface; | ||||
| 
 | ||||
| use Psr\Http\Server\{ RequestHandlerInterface, MiddlewareInterface }; | ||||
| use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface }; | ||||
| use Storage\Session; | ||||
| 
 | ||||
| class Authentication implements MiddlewareInterface { | ||||
| @ -23,9 +20,6 @@ class Authentication implements MiddlewareInterface { | ||||
|         $this->session = $session; | ||||
|     } | ||||
| 
 | ||||
|     #[param  ServerRequestInterface  $request]
 | ||||
|     #[param  RequestHandlerInterface $handler]
 | ||||
|     #[return ResponseInterface]
 | ||||
|     public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface | ||||
|     { | ||||
|         $user = $this->session->get( $this->sessionUserVariable() ); | ||||
| @ -37,8 +31,6 @@ class Authentication implements MiddlewareInterface { | ||||
|         return $handler->handle($request); | ||||
|     } | ||||
| 
 | ||||
|     #[param string|null sessionUserVariable]
 | ||||
|     #[return mixed]
 | ||||
|     public function sessionUserVariable(?string $set = null) : string | ||||
|     { | ||||
|         return $set !== null ? $this->sessionUserVariable = $set : $this->sessionUserVariable; | ||||
|  | ||||
| @ -5,7 +5,6 @@ | ||||
|             <meta charset="UTF-8" /> | ||||
|             <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | ||||
|             <title>{% section "head.title" %}{{ title() }} — {{ lang('application_name') }}{% endsection %}</title> | ||||
|             </style> | ||||
|         </head> | ||||
|     {% endsection %} | ||||
| 
 | ||||
|  | ||||
| @ -6,4 +6,8 @@ | ||||
|     <div class="main"> | ||||
|         Hello World :) ! | ||||
|     </div> | ||||
| 
 | ||||
|     <div> | ||||
|         <a href="{% route 'lean.console:home' %}">Accéder à la console LEAN</a> | ||||
|     </div> | ||||
| {% endsection %} | ||||
| @ -51,7 +51,11 @@ trait ControllerTrait { | ||||
| 
 | ||||
|     public function renderRawView(string $view, ?array $variables = null) : string | ||||
|     { | ||||
|         return $this->picea->renderHtml($view, $variables ?? [], $this); | ||||
|         if ( null === $content = $this->picea->renderHtml($view, $variables ?? [], $this) ) { | ||||
|             throw new \RuntimeException("Picea's renderHtml() returned NULL as result ; an error occured within your template `$view`."); | ||||
|         } | ||||
| 
 | ||||
|         return $content; | ||||
|     } | ||||
| 
 | ||||
|     public function renderView(string $view, ?array $variables = null) : ResponseInterface | ||||
|  | ||||
							
								
								
									
										43
									
								
								src/File.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								src/File.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | ||||
| <?php | ||||
| 
 | ||||
| namespace Lean; | ||||
| 
 | ||||
| class File | ||||
| { | ||||
|     public static function tail(string $path, int $lines = 10) : false|array | ||||
|     { | ||||
|         $handle = fopen($path, "r"); | ||||
| 
 | ||||
|         $counter = $lines; | ||||
| 
 | ||||
|         $pos = -2; | ||||
|         $beginning = false; | ||||
|         $text = array(); | ||||
| 
 | ||||
|         while ($counter && ! $beginning) { | ||||
|             $t = ""; | ||||
| 
 | ||||
|             while ($t !== PHP_EOL) { | ||||
|                 if(fseek($handle, $pos, SEEK_END) == -1) { | ||||
|                     $beginning = true; | ||||
|                     break; | ||||
|                 } | ||||
| 
 | ||||
|                 $t = fgetc($handle); | ||||
|                 $pos --; | ||||
|             } | ||||
| 
 | ||||
|             $counter --; | ||||
| 
 | ||||
|             if ($beginning) { | ||||
|                 rewind($handle); | ||||
|             } | ||||
| 
 | ||||
|             $text[$lines - $counter - 1] = fgets($handle); | ||||
|         } | ||||
| 
 | ||||
|         fclose ($handle); | ||||
| 
 | ||||
|         return array_reverse($text); | ||||
|     } | ||||
| } | ||||
| @ -133,7 +133,7 @@ class Lean | ||||
|         $path = dirname(__DIR__) . "/meta/definitions/"; | ||||
| 
 | ||||
|         return array_merge( | ||||
|             class_exists(\Mcnd\CLI\Middleware::class) ? require($path . "cli.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"), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user