2019-03-18 16:53:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FireflyIII\Console\Commands\Upgrade;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
/**
|
2022-01-09 08:19:28 +01:00
|
|
|
* Class UpgradeSkeleton.
|
|
|
|
* TODO DONT FORGET TO ADD THIS TO THE DOCKER BUILD
|
2019-03-18 16:53:05 +01:00
|
|
|
*/
|
|
|
|
class UpgradeSkeleton extends Command
|
|
|
|
{
|
2023-10-22 07:51:26 +02:00
|
|
|
use ShowsFriendlyMessages;
|
2023-12-02 12:56:48 +01:00
|
|
|
public const string CONFIG_NAME = '480_some_name';
|
2023-11-05 09:54:53 +01:00
|
|
|
|
2019-03-18 16:53:05 +01:00
|
|
|
protected $description = 'SOME DESCRIPTION';
|
2023-11-05 09:54:53 +01:00
|
|
|
|
2019-03-23 08:10:59 +01:00
|
|
|
protected $signature = 'firefly-iii:UPGRSKELETON {--F|force : Force the execution of this command.}';
|
2019-03-18 16:53:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function handle(): int
|
|
|
|
{
|
2019-06-21 19:07:11 +02:00
|
|
|
$start = microtime(true);
|
2019-03-18 16:53:05 +01:00
|
|
|
if ($this->isExecuted() && true !== $this->option('force')) {
|
2024-03-16 07:03:50 +01:00
|
|
|
$this->friendlyInfo('This command has already been executed.');
|
2019-03-18 16:53:05 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2024-03-16 07:03:50 +01:00
|
|
|
$this->friendlyWarning('Congrats, you found the skeleton command. Boo!');
|
2019-03-18 16:53:05 +01:00
|
|
|
|
|
|
|
//$this->markAsExecuted();
|
2019-06-21 19:07:11 +02:00
|
|
|
|
|
|
|
$end = round(microtime(true) - $start, 2);
|
|
|
|
$this->info(sprintf('in %s seconds.', $end));
|
|
|
|
|
2019-03-18 16:53:05 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
private function isExecuted(): bool
|
|
|
|
{
|
|
|
|
$configVar = app('fireflyconfig')->get(self::CONFIG_NAME, false);
|
|
|
|
if (null !== $configVar) {
|
|
|
|
return (bool)$configVar->data;
|
|
|
|
}
|
|
|
|
|
2021-04-07 07:28:43 +02:00
|
|
|
return false;
|
2019-03-18 16:53:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private function markAsExecuted(): void
|
|
|
|
{
|
|
|
|
app('fireflyconfig')->set(self::CONFIG_NAME, true);
|
|
|
|
}
|
|
|
|
}
|