Commaaa2
This commit is contained in:
9
vendor/laravel/framework/src/Illuminate/Console/Application.php
vendored
Normal file → Executable file
9
vendor/laravel/framework/src/Illuminate/Console/Application.php
vendored
Normal file → Executable file
@@ -19,7 +19,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Process\PhpExecutableFinder;
|
||||
|
||||
@@ -77,6 +76,8 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function run(InputInterface $input = null, OutputInterface $output = null)
|
||||
{
|
||||
@@ -86,7 +87,7 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
|
||||
$this->events->dispatch(
|
||||
new CommandStarting(
|
||||
$commandName, $input, $output = $output ?: new ConsoleOutput
|
||||
$commandName, $input, $output = $output ?: new BufferedConsoleOutput
|
||||
)
|
||||
);
|
||||
|
||||
@@ -116,7 +117,7 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
*/
|
||||
public static function artisanBinary()
|
||||
{
|
||||
return defined('ARTISAN_BINARY') ? ProcessUtils::escapeArgument(ARTISAN_BINARY) : 'artisan';
|
||||
return ProcessUtils::escapeArgument(defined('ARTISAN_BINARY') ? ARTISAN_BINARY : 'artisan');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,7 +210,7 @@ class Application extends SymfonyApplication implements ApplicationContract
|
||||
$input = new ArrayInput($parameters);
|
||||
}
|
||||
|
||||
return [$command, $input ?? null];
|
||||
return [$command, $input];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
12
vendor/laravel/framework/src/Illuminate/Console/Command.php
vendored
Normal file → Executable file
12
vendor/laravel/framework/src/Illuminate/Console/Command.php
vendored
Normal file → Executable file
@@ -38,14 +38,14 @@ class Command extends SymfonyCommand
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string|null
|
||||
* @var string
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* The console command help text.
|
||||
*
|
||||
* @var string|null
|
||||
* @var string
|
||||
*/
|
||||
protected $help;
|
||||
|
||||
@@ -131,7 +131,9 @@ class Command extends SymfonyCommand
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
return (int) $this->laravel->call([$this, 'handle']);
|
||||
$method = method_exists($this, 'handle') ? 'handle' : '__invoke';
|
||||
|
||||
return (int) $this->laravel->call([$this, $method]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,6 +163,8 @@ class Command extends SymfonyCommand
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isHidden()
|
||||
{
|
||||
@@ -169,6 +173,8 @@ class Command extends SymfonyCommand
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function setHidden(bool $hidden)
|
||||
{
|
||||
|
||||
@@ -29,7 +29,7 @@ trait CallsCommands
|
||||
}
|
||||
|
||||
/**
|
||||
* Call another console command silently.
|
||||
* Call another console command without output.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Command\Command|string $command
|
||||
* @param array $arguments
|
||||
@@ -40,6 +40,18 @@ trait CallsCommands
|
||||
return $this->runCommand($command, $arguments, new NullOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call another console command without output.
|
||||
*
|
||||
* @param \Symfony\Component\Console\Command\Command|string $command
|
||||
* @param array $arguments
|
||||
* @return int
|
||||
*/
|
||||
public function callSilently($command, array $arguments = [])
|
||||
{
|
||||
return $this->callSilent($command, $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the given the console command.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Console\Concerns;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Console\OutputStyle;
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -237,6 +238,38 @@ trait InteractsWithIO
|
||||
$table->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a given callback while advancing a progress bar.
|
||||
*
|
||||
* @param iterable|int $totalSteps
|
||||
* @param \Closure $callback
|
||||
* @return mixed|void
|
||||
*/
|
||||
public function withProgressBar($totalSteps, Closure $callback)
|
||||
{
|
||||
$bar = $this->output->createProgressBar(
|
||||
is_iterable($totalSteps) ? count($totalSteps) : $totalSteps
|
||||
);
|
||||
|
||||
$bar->start();
|
||||
|
||||
if (is_iterable($totalSteps)) {
|
||||
foreach ($totalSteps as $value) {
|
||||
$callback($value, $bar);
|
||||
|
||||
$bar->advance();
|
||||
}
|
||||
} else {
|
||||
$callback($bar);
|
||||
}
|
||||
|
||||
$bar->finish();
|
||||
|
||||
if (is_iterable($totalSteps)) {
|
||||
return $totalSteps;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a string as information output.
|
||||
*
|
||||
@@ -332,7 +365,18 @@ trait InteractsWithIO
|
||||
$this->comment('* '.$string.' *');
|
||||
$this->comment(str_repeat('*', $length));
|
||||
|
||||
$this->output->newLine();
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a blank line.
|
||||
*
|
||||
* @param int $count
|
||||
* @return void
|
||||
*/
|
||||
public function newLine($count = 1)
|
||||
{
|
||||
$this->output->newLine($count);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ class ScheduledTaskFailed
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Event $task
|
||||
* @param \Throwable $exception
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Event $task, Throwable $exception)
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Illuminate\Console;
|
||||
|
||||
use Illuminate\Console\Concerns\CreatesMatchingTest;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -25,7 +26,7 @@ abstract class GeneratorCommand extends Command
|
||||
/**
|
||||
* Reserved names that cannot be used for generation.
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
protected $reservedNames = [
|
||||
'__halt_compiler',
|
||||
@@ -108,6 +109,10 @@ abstract class GeneratorCommand extends Command
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {
|
||||
$this->addTestOptions();
|
||||
}
|
||||
|
||||
$this->files = $files;
|
||||
}
|
||||
|
||||
@@ -159,6 +164,10 @@ abstract class GeneratorCommand extends Command
|
||||
$this->files->put($path, $this->sortImports($this->buildClass($name)));
|
||||
|
||||
$this->info($this->type.' created successfully.');
|
||||
|
||||
if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {
|
||||
$this->handleTestCreation($path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,19 +180,42 @@ abstract class GeneratorCommand extends Command
|
||||
{
|
||||
$name = ltrim($name, '\\/');
|
||||
|
||||
$name = str_replace('/', '\\', $name);
|
||||
|
||||
$rootNamespace = $this->rootNamespace();
|
||||
|
||||
if (Str::startsWith($name, $rootNamespace)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
$name = str_replace('/', '\\', $name);
|
||||
|
||||
return $this->qualifyClass(
|
||||
$this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Qualify the given model class base name.
|
||||
*
|
||||
* @param string $model
|
||||
* @return string
|
||||
*/
|
||||
protected function qualifyModel(string $model)
|
||||
{
|
||||
$model = ltrim($model, '\\/');
|
||||
|
||||
$model = str_replace('/', '\\', $model);
|
||||
|
||||
$rootNamespace = $this->rootNamespace();
|
||||
|
||||
if (Str::startsWith($model, $rootNamespace)) {
|
||||
return $model;
|
||||
}
|
||||
|
||||
return is_dir(app_path('Models'))
|
||||
? $rootNamespace.'Models\\'.$model
|
||||
: $rootNamespace.$model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default namespace for the class.
|
||||
*
|
||||
|
||||
@@ -68,4 +68,14 @@ class OutputStyle extends SymfonyStyle
|
||||
{
|
||||
return $this->output->isDebug();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the underlying Symfony output implementation.
|
||||
*
|
||||
* @return \Symfony\Component\Console\Output\OutputInterface
|
||||
*/
|
||||
public function getOutput()
|
||||
{
|
||||
return $this->output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Support\Reflector;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use Throwable;
|
||||
|
||||
class CallbackEvent extends Event
|
||||
{
|
||||
@@ -77,6 +78,12 @@ class CallbackEvent extends Event
|
||||
$response = is_object($this->callback)
|
||||
? $container->call([$this->callback, '__invoke'], $this->parameters)
|
||||
: $container->call($this->callback, $this->parameters);
|
||||
|
||||
$this->exitCode = $response === false ? 1 : 0;
|
||||
} catch (Throwable $e) {
|
||||
$this->exitCode = 1;
|
||||
|
||||
throw $e;
|
||||
} finally {
|
||||
$this->removeMutex();
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class CommandBuilder
|
||||
$finished = Application::formatCommandString('schedule:finish').' "'.$event->mutexName().'"';
|
||||
|
||||
if (windows_os()) {
|
||||
return 'start /b cmd /c "('.$event->command.' & '.$finished.' "%errorlevel%")'.$redirect.$output.' 2>&1"';
|
||||
return 'start /b cmd /v:on /c "('.$event->command.' & '.$finished.' ^!ERRORLEVEL^!)'.$redirect.$output.' 2>&1"';
|
||||
}
|
||||
|
||||
return $this->ensureCorrectUser($event,
|
||||
|
||||
@@ -10,13 +10,14 @@ use Illuminate\Contracts\Container\Container;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\Date;
|
||||
use Illuminate\Support\Reflector;
|
||||
use Illuminate\Support\Stringable;
|
||||
use Illuminate\Support\Traits\Macroable;
|
||||
use Illuminate\Support\Traits\ReflectsClosures;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Throwable;
|
||||
|
||||
class Event
|
||||
{
|
||||
@@ -86,7 +87,7 @@ class Event
|
||||
public $expiresAt = 1440;
|
||||
|
||||
/**
|
||||
* Indicates if the command should run in background.
|
||||
* Indicates if the command should run in the background.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
@@ -218,11 +219,17 @@ class Event
|
||||
*/
|
||||
protected function runCommandInForeground(Container $container)
|
||||
{
|
||||
$this->callBeforeCallbacks($container);
|
||||
try {
|
||||
$this->callBeforeCallbacks($container);
|
||||
|
||||
$this->exitCode = Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
$this->exitCode = Process::fromShellCommandline(
|
||||
$this->buildCommand(), base_path(), null, null, null
|
||||
)->run();
|
||||
|
||||
$this->callAfterCallbacks($container);
|
||||
$this->callAfterCallbacks($container);
|
||||
} finally {
|
||||
$this->removeMutex();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -233,9 +240,15 @@ class Event
|
||||
*/
|
||||
protected function runCommandInBackground(Container $container)
|
||||
{
|
||||
$this->callBeforeCallbacks($container);
|
||||
try {
|
||||
$this->callBeforeCallbacks($container);
|
||||
|
||||
Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
Process::fromShellCommandline($this->buildCommand(), base_path(), null, null, null)->run();
|
||||
} catch (Throwable $exception) {
|
||||
$this->removeMutex();
|
||||
|
||||
throw $exception;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,7 +288,11 @@ class Event
|
||||
{
|
||||
$this->exitCode = (int) $exitCode;
|
||||
|
||||
$this->callAfterCallbacks($container);
|
||||
try {
|
||||
$this->callAfterCallbacks($container);
|
||||
} finally {
|
||||
$this->removeMutex();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,13 +338,13 @@ class Event
|
||||
*/
|
||||
protected function expressionPasses()
|
||||
{
|
||||
$date = Carbon::now();
|
||||
$date = Date::now();
|
||||
|
||||
if ($this->timezone) {
|
||||
$date->setTimezone($this->timezone);
|
||||
$date = $date->setTimezone($this->timezone);
|
||||
}
|
||||
|
||||
return CronExpression::factory($this->expression)->isDue($date->toDateTimeString());
|
||||
return (new CronExpression($this->expression))->isDue($date->toDateTimeString());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,7 +492,7 @@ class Event
|
||||
*/
|
||||
protected function emailOutput(Mailer $mailer, $addresses, $onlyIfOutputExists = false)
|
||||
{
|
||||
$text = file_exists($this->output) ? file_get_contents($this->output) : '';
|
||||
$text = is_file($this->output) ? file_get_contents($this->output) : '';
|
||||
|
||||
if ($onlyIfOutputExists && empty($text)) {
|
||||
return;
|
||||
@@ -586,7 +603,7 @@ class Event
|
||||
}
|
||||
|
||||
/**
|
||||
* State that the command should run in background.
|
||||
* State that the command should run in the background.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
@@ -647,9 +664,7 @@ class Event
|
||||
|
||||
$this->expiresAt = $expiresAt;
|
||||
|
||||
return $this->then(function () {
|
||||
$this->mutex->forget($this);
|
||||
})->skip(function () {
|
||||
return $this->skip(function () {
|
||||
return $this->mutex->exists($this);
|
||||
});
|
||||
}
|
||||
@@ -728,6 +743,12 @@ class Event
|
||||
*/
|
||||
public function then(Closure $callback)
|
||||
{
|
||||
$parameters = $this->closureParameterTypes($callback);
|
||||
|
||||
if (Arr::get($parameters, 'output') === Stringable::class) {
|
||||
return $this->thenWithOutput($callback);
|
||||
}
|
||||
|
||||
$this->afterCallbacks[] = $callback;
|
||||
|
||||
return $this;
|
||||
@@ -755,6 +776,12 @@ class Event
|
||||
*/
|
||||
public function onSuccess(Closure $callback)
|
||||
{
|
||||
$parameters = $this->closureParameterTypes($callback);
|
||||
|
||||
if (Arr::get($parameters, 'output') === Stringable::class) {
|
||||
return $this->onSuccessWithOutput($callback);
|
||||
}
|
||||
|
||||
return $this->then(function (Container $container) use ($callback) {
|
||||
if (0 === $this->exitCode) {
|
||||
$container->call($callback);
|
||||
@@ -784,6 +811,12 @@ class Event
|
||||
*/
|
||||
public function onFailure(Closure $callback)
|
||||
{
|
||||
$parameters = $this->closureParameterTypes($callback);
|
||||
|
||||
if (Arr::get($parameters, 'output') === Stringable::class) {
|
||||
return $this->onFailureWithOutput($callback);
|
||||
}
|
||||
|
||||
return $this->then(function (Container $container) use ($callback) {
|
||||
if (0 !== $this->exitCode) {
|
||||
$container->call($callback);
|
||||
@@ -815,11 +848,11 @@ class Event
|
||||
protected function withOutputCallback(Closure $callback, $onlyIfOutputExists = false)
|
||||
{
|
||||
return function (Container $container) use ($callback, $onlyIfOutputExists) {
|
||||
$output = $this->output && file_exists($this->output) ? file_get_contents($this->output) : '';
|
||||
$output = $this->output && is_file($this->output) ? file_get_contents($this->output) : '';
|
||||
|
||||
return $onlyIfOutputExists && empty($output)
|
||||
? null
|
||||
: $container->call($callback, ['output' => $output]);
|
||||
: $container->call($callback, ['output' => new Stringable($output)]);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -871,9 +904,8 @@ class Event
|
||||
*/
|
||||
public function nextRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false)
|
||||
{
|
||||
return Date::instance(CronExpression::factory(
|
||||
$this->getExpression()
|
||||
)->getNextRunDate($currentTime, $nth, $allowCurrentDate, $this->timezone));
|
||||
return Date::instance((new CronExpression($this->getExpression()))
|
||||
->getNextRunDate($currentTime, $nth, $allowCurrentDate, $this->timezone));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -898,4 +930,16 @@ class Event
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the mutex for the event.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function removeMutex()
|
||||
{
|
||||
if ($this->withoutOverlapping) {
|
||||
$this->mutex->forget($this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,10 +262,23 @@ trait ManagesFrequencies
|
||||
* @return $this
|
||||
*/
|
||||
public function twiceDaily($first = 1, $second = 13)
|
||||
{
|
||||
return $this->twiceDailyAt($first, $second, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the event to run twice daily at a given offset.
|
||||
*
|
||||
* @param int $first
|
||||
* @param int $second
|
||||
* @param int $offset
|
||||
* @return $this
|
||||
*/
|
||||
public function twiceDailyAt($first = 1, $second = 13, $offset = 0)
|
||||
{
|
||||
$hours = $first.','.$second;
|
||||
|
||||
return $this->spliceIntoPosition(1, 0)
|
||||
return $this->spliceIntoPosition(1, $offset)
|
||||
->spliceIntoPosition(2, $hours);
|
||||
}
|
||||
|
||||
@@ -276,7 +289,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function weekdays()
|
||||
{
|
||||
return $this->spliceIntoPosition(5, '1-5');
|
||||
return $this->days(Schedule::MONDAY.'-'.Schedule::FRIDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,7 +299,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function weekends()
|
||||
{
|
||||
return $this->spliceIntoPosition(5, '0,6');
|
||||
return $this->days(Schedule::SATURDAY.','.Schedule::SUNDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -296,7 +309,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function mondays()
|
||||
{
|
||||
return $this->days(1);
|
||||
return $this->days(Schedule::MONDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +319,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function tuesdays()
|
||||
{
|
||||
return $this->days(2);
|
||||
return $this->days(Schedule::TUESDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -316,7 +329,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function wednesdays()
|
||||
{
|
||||
return $this->days(3);
|
||||
return $this->days(Schedule::WEDNESDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -326,7 +339,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function thursdays()
|
||||
{
|
||||
return $this->days(4);
|
||||
return $this->days(Schedule::THURSDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -336,7 +349,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function fridays()
|
||||
{
|
||||
return $this->days(5);
|
||||
return $this->days(Schedule::FRIDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,7 +359,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function saturdays()
|
||||
{
|
||||
return $this->days(6);
|
||||
return $this->days(Schedule::SATURDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,7 +369,7 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function sundays()
|
||||
{
|
||||
return $this->days(0);
|
||||
return $this->days(Schedule::SUNDAY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,15 +387,15 @@ trait ManagesFrequencies
|
||||
/**
|
||||
* Schedule the event to run weekly on a given day and time.
|
||||
*
|
||||
* @param int $day
|
||||
* @param array|mixed $dayOfWeek
|
||||
* @param string $time
|
||||
* @return $this
|
||||
*/
|
||||
public function weeklyOn($day, $time = '0:0')
|
||||
public function weeklyOn($dayOfWeek, $time = '0:0')
|
||||
{
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(5, $day);
|
||||
return $this->days($dayOfWeek);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,15 +413,15 @@ trait ManagesFrequencies
|
||||
/**
|
||||
* Schedule the event to run monthly on a given day and time.
|
||||
*
|
||||
* @param int $day
|
||||
* @param int $dayOfMonth
|
||||
* @param string $time
|
||||
* @return $this
|
||||
*/
|
||||
public function monthlyOn($day = 1, $time = '0:0')
|
||||
public function monthlyOn($dayOfMonth = 1, $time = '0:0')
|
||||
{
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(3, $day);
|
||||
return $this->spliceIntoPosition(3, $dayOfMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,13 +434,11 @@ trait ManagesFrequencies
|
||||
*/
|
||||
public function twiceMonthly($first = 1, $second = 16, $time = '0:0')
|
||||
{
|
||||
$days = $first.','.$second;
|
||||
$daysOfMonth = $first.','.$second;
|
||||
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(1, 0)
|
||||
->spliceIntoPosition(2, 0)
|
||||
->spliceIntoPosition(3, $days);
|
||||
return $this->spliceIntoPosition(3, $daysOfMonth);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,6 +480,22 @@ trait ManagesFrequencies
|
||||
->spliceIntoPosition(4, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule the event to run yearly on a given month, day, and time.
|
||||
*
|
||||
* @param int $month
|
||||
* @param int|string $dayOfMonth
|
||||
* @param string $time
|
||||
* @return $this
|
||||
*/
|
||||
public function yearlyOn($month = 1, $dayOfMonth = 1, $time = '0:0')
|
||||
{
|
||||
$this->dailyAt($time);
|
||||
|
||||
return $this->spliceIntoPosition(3, $dayOfMonth)
|
||||
->spliceIntoPosition(4, $month);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the days of the week the command should run on.
|
||||
*
|
||||
|
||||
@@ -4,10 +4,13 @@ namespace Illuminate\Console\Scheduling;
|
||||
|
||||
use Closure;
|
||||
use DateTimeInterface;
|
||||
use Illuminate\Bus\UniqueLock;
|
||||
use Illuminate\Console\Application;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Contracts\Bus\Dispatcher;
|
||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||
use Illuminate\Contracts\Container\BindingResolutionException;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\CallQueuedClosure;
|
||||
use Illuminate\Support\ProcessUtils;
|
||||
@@ -19,6 +22,14 @@ class Schedule
|
||||
{
|
||||
use Macroable;
|
||||
|
||||
const SUNDAY = 0;
|
||||
const MONDAY = 1;
|
||||
const TUESDAY = 2;
|
||||
const WEDNESDAY = 3;
|
||||
const THURSDAY = 4;
|
||||
const FRIDAY = 5;
|
||||
const SATURDAY = 6;
|
||||
|
||||
/**
|
||||
* All of the events on the schedule.
|
||||
*
|
||||
@@ -59,6 +70,8 @@ class Schedule
|
||||
*
|
||||
* @param \DateTimeZone|string|null $timezone
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function __construct($timezone = null)
|
||||
{
|
||||
@@ -107,7 +120,11 @@ class Schedule
|
||||
public function command($command, array $parameters = [])
|
||||
{
|
||||
if (class_exists($command)) {
|
||||
$command = Container::getInstance()->make($command)->getName();
|
||||
$command = Container::getInstance()->make($command);
|
||||
|
||||
return $this->exec(
|
||||
Application::formatCommandString($command->getName()), $parameters,
|
||||
)->description($command->getDescription());
|
||||
}
|
||||
|
||||
return $this->exec(
|
||||
@@ -143,6 +160,8 @@ class Schedule
|
||||
* @param string|null $queue
|
||||
* @param string|null $connection
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function dispatchToQueue($job, $queue, $connection)
|
||||
{
|
||||
@@ -156,6 +175,35 @@ class Schedule
|
||||
$job = CallQueuedClosure::create($job);
|
||||
}
|
||||
|
||||
if ($job instanceof ShouldBeUnique) {
|
||||
return $this->dispatchUniqueJobToQueue($job, $queue, $connection);
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch(
|
||||
$job->onConnection($connection)->onQueue($queue)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch the given unique job to the queue.
|
||||
*
|
||||
* @param object $job
|
||||
* @param string|null $queue
|
||||
* @param string|null $connection
|
||||
* @return void
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function dispatchUniqueJobToQueue($job, $queue, $connection)
|
||||
{
|
||||
if (! Container::getInstance()->bound(Cache::class)) {
|
||||
throw new RuntimeException('Cache driver not available. Scheduling unique jobs not supported.');
|
||||
}
|
||||
|
||||
if (! (new UniqueLock(Container::getInstance()->make(Cache::class)))->acquire($job)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->getDispatcher()->dispatch(
|
||||
$job->onConnection($connection)->onQueue($queue)
|
||||
);
|
||||
@@ -293,6 +341,8 @@ class Schedule
|
||||
* Get the job dispatcher, if available.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Bus\Dispatcher
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
protected function getDispatcher()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
namespace Illuminate\Console\Scheduling;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Console\Events\ScheduledBackgroundTaskFinished;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
|
||||
class ScheduleFinishCommand extends Command
|
||||
{
|
||||
@@ -37,6 +39,10 @@ class ScheduleFinishCommand extends Command
|
||||
{
|
||||
collect($schedule->events())->filter(function ($value) {
|
||||
return $value->mutexName() == $this->argument('id');
|
||||
})->each->callAfterCallbacksWithExitCode($this->laravel, $this->argument('code'));
|
||||
})->each(function ($event) {
|
||||
$event->callafterCallbacksWithExitCode($this->laravel, $this->argument('code'));
|
||||
|
||||
$this->laravel->make(Dispatcher::class)->dispatch(new ScheduledBackgroundTaskFinished($event));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ class ScheduleRunCommand extends Command
|
||||
*/
|
||||
protected function runEvent($event)
|
||||
{
|
||||
$this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
|
||||
$this->line('<info>['.date('c').'] Running scheduled command:</info> '.$event->getSummaryForDisplay());
|
||||
|
||||
$this->dispatcher->dispatch(new ScheduledTaskStarting($event));
|
||||
|
||||
|
||||
26
vendor/laravel/framework/src/Illuminate/Console/composer.json
vendored
Normal file → Executable file
26
vendor/laravel/framework/src/Illuminate/Console/composer.json
vendored
Normal file → Executable file
@@ -14,11 +14,13 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5|^8.0",
|
||||
"illuminate/contracts": "^7.0",
|
||||
"illuminate/support": "^7.0",
|
||||
"symfony/console": "^5.0",
|
||||
"symfony/process": "^5.0"
|
||||
"php": "^7.3|^8.0",
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/macroable": "^8.0",
|
||||
"illuminate/support": "^8.0",
|
||||
"symfony/console": "^5.4",
|
||||
"symfony/process": "^5.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
@@ -27,16 +29,16 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "7.x-dev"
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"suggest": {
|
||||
"dragonmantank/cron-expression": "Required to use scheduler (^2.3.1).",
|
||||
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.3.1|^7.0.1).",
|
||||
"illuminate/bus": "Required to use the scheduled job dispatcher (^7.0).",
|
||||
"illuminate/container": "Required to use the scheduler (^7.0).",
|
||||
"illuminate/filesystem": "Required to use the generator command (^7.0).",
|
||||
"illuminate/queue": "Required to use closures for scheduled jobs (^7.0)."
|
||||
"dragonmantank/cron-expression": "Required to use scheduler (^3.0.2).",
|
||||
"guzzlehttp/guzzle": "Required to use the ping methods on schedules (^6.5.5|^7.0.1).",
|
||||
"illuminate/bus": "Required to use the scheduled job dispatcher (^8.0).",
|
||||
"illuminate/container": "Required to use the scheduler (^8.0).",
|
||||
"illuminate/filesystem": "Required to use the generator command (^8.0).",
|
||||
"illuminate/queue": "Required to use closures for scheduled jobs (^8.0)."
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
|
||||
Reference in New Issue
Block a user