mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-10-31 18:54:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			71 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			71 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace FireflyIII\Console\Commands\Upgrade;
 | |
| 
 | |
| use Illuminate\Console\Command;
 | |
| 
 | |
| /**
 | |
|  * Class UpgradeSkeleton
 | |
|  */
 | |
| class UpgradeSkeleton extends Command
 | |
| {
 | |
|     public const CONFIG_NAME = '480_some_name';
 | |
|     /**
 | |
|      * The console command description.
 | |
|      *
 | |
|      * @var string
 | |
|      */
 | |
|     protected $description = 'SOME DESCRIPTION';
 | |
|     /**
 | |
|      * The name and signature of the console command.
 | |
|      *
 | |
|      * @var string
 | |
|      */
 | |
|     protected $signature = 'firefly-iii:UPGRSKELETON {--F|force : Force the execution of this command.}';
 | |
| 
 | |
|     /**
 | |
|      * Execute the console command.
 | |
|      *
 | |
|      * @return int
 | |
|      */
 | |
|     public function handle(): int
 | |
|     {
 | |
|         $start = microtime(true);
 | |
|         if ($this->isExecuted() && true !== $this->option('force')) {
 | |
|             $this->warn('This command has already been executed.');
 | |
| 
 | |
|             return 0;
 | |
|         }
 | |
|         $this->warn('Congrats, you found the skeleton command. Boo!');
 | |
| 
 | |
|         //$this->markAsExecuted();
 | |
| 
 | |
|         $end = round(microtime(true) - $start, 2);
 | |
|         $this->info(sprintf('in %s seconds.', $end));
 | |
| 
 | |
|         return 0;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * @return bool
 | |
|      */
 | |
|     private function isExecuted(): bool
 | |
|     {
 | |
|         $configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
 | |
|         if (null !== $configVar) {
 | |
|             return (bool)$configVar->data;
 | |
|         }
 | |
| 
 | |
|         return false; // @codeCoverageIgnore
 | |
|     }
 | |
| 
 | |
| 
 | |
|     /**
 | |
|      *
 | |
|      */
 | |
|     private function markAsExecuted(): void
 | |
|     {
 | |
|         app('fireflyconfig')->set(self::CONFIG_NAME, true);
 | |
|     }
 | |
| }
 |