2016-01-08 09:02:15 -06:00
|
|
|
<?php
|
2018-05-11 03:08:34 -05:00
|
|
|
|
2017-10-21 01:40:00 -05:00
|
|
|
/**
|
|
|
|
* Kernel.php
|
2018-05-11 03:08:34 -05:00
|
|
|
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
|
|
|
* This file is part of Firefly III.
|
|
|
|
*
|
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 07:41:58 -06:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2017-10-21 01:40:00 -05:00
|
|
|
*/
|
2017-09-14 10:40:02 -05:00
|
|
|
|
2018-05-11 03:08:34 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-01-08 09:02:15 -06:00
|
|
|
namespace FireflyIII\Console;
|
2015-02-05 21:39:52 -06:00
|
|
|
|
2018-06-22 11:42:23 -05:00
|
|
|
use Carbon\Carbon;
|
|
|
|
use FireflyIII\Jobs\CreateRecurringTransactions;
|
|
|
|
use FireflyIII\Models\RecurrenceRepetition;
|
|
|
|
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
2017-09-09 14:57:24 -05:00
|
|
|
use Illuminate\Console\Scheduling\Schedule;
|
2015-02-05 21:39:52 -06:00
|
|
|
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
|
2018-06-22 11:42:23 -05:00
|
|
|
use Log;
|
2015-02-05 21:39:52 -06:00
|
|
|
|
2017-09-16 00:41:03 -05:00
|
|
|
/**
|
|
|
|
* File to make sure commnds work.
|
|
|
|
*/
|
2015-02-11 00:35:10 -06:00
|
|
|
class Kernel extends ConsoleKernel
|
|
|
|
{
|
2016-04-08 07:44:53 -05:00
|
|
|
/**
|
2017-09-09 14:57:24 -05:00
|
|
|
* The Artisan commands provided by your application.
|
2016-04-08 07:44:53 -05:00
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
2017-09-14 10:40:02 -05:00
|
|
|
protected $commands
|
|
|
|
= [
|
|
|
|
];
|
2016-04-08 07:44:53 -05:00
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
/**
|
2017-09-14 10:40:02 -05:00
|
|
|
* Register the commands for the application.
|
2015-02-11 00:35:10 -06:00
|
|
|
*/
|
2017-09-14 10:40:02 -05:00
|
|
|
protected function commands()
|
2017-09-09 14:57:24 -05:00
|
|
|
{
|
2017-09-14 10:40:02 -05:00
|
|
|
$this->load(__DIR__ . '/Commands');
|
|
|
|
|
|
|
|
require base_path('routes/console.php');
|
2017-09-09 14:57:24 -05:00
|
|
|
}
|
2016-09-15 23:40:45 -05:00
|
|
|
|
|
|
|
/**
|
2017-09-14 10:40:02 -05:00
|
|
|
* Define the application's command schedule.
|
|
|
|
*
|
2017-11-15 05:25:49 -06:00
|
|
|
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
2017-10-06 08:41:21 -05:00
|
|
|
*
|
2017-09-16 02:24:48 -05:00
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
|
2016-09-15 23:40:45 -05:00
|
|
|
*/
|
2018-06-22 11:42:23 -05:00
|
|
|
protected function schedule(Schedule $schedule): void
|
2016-09-15 23:40:45 -05:00
|
|
|
{
|
2018-06-22 11:42:23 -05:00
|
|
|
$schedule->call(
|
|
|
|
function () {
|
|
|
|
// run for the entirety of 2018, just to see what happens
|
|
|
|
$start = new Carbon('2018-01-01');
|
|
|
|
$end = new Carbon('2018-12-31');
|
|
|
|
while ($start <= $end) {
|
|
|
|
Log::info(sprintf('Now at %s', $start->format('D Y-m-d')));
|
|
|
|
$job = new CreateRecurringTransactions(clone $start);
|
|
|
|
$job->handle();
|
|
|
|
$start->addDay();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
)->everyMinute();
|
|
|
|
|
|
|
|
//$schedule->job(new CreateRecurringTransactions(new Carbon))->everyMinute();
|
|
|
|
|
|
|
|
//$schedule->job(new CreateRecurringTransactions(new Carbon))->everyMinute();
|
|
|
|
|
|
|
|
|
|
|
|
// $schedule->call(
|
|
|
|
// function () {
|
|
|
|
// // command to do something
|
|
|
|
// Log::debug('Schedule creation of transactions yaay!');
|
|
|
|
// }
|
|
|
|
// )->daily();
|
|
|
|
//
|
|
|
|
// $schedule->call(
|
|
|
|
// function () {
|
|
|
|
// // command to do something
|
|
|
|
// Log::debug('Every minute!');
|
|
|
|
// }
|
|
|
|
// )->everyMinute()
|
|
|
|
// ->emailOutputTo('thege');
|
|
|
|
|
|
|
|
|
2016-09-15 23:40:45 -05:00
|
|
|
}
|
2015-02-05 21:39:52 -06:00
|
|
|
}
|