- WIP on File lib and CLI's definition
This commit is contained in:
		
							parent
							
								
									777f4af1aa
								
							
						
					
					
						commit
						2e51ff9f4a
					
				| @ -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')); | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										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