Server IP : 173.249.157.85 / Your IP : 18.188.216.102 Web Server : Apache System : Linux server.frogzhost.com 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 User : econtech ( 1005) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/econtech/www/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ |
Upload File : |
<?php namespace Illuminate\Console\Scheduling; use LogicException; use InvalidArgumentException; use Illuminate\Contracts\Container\Container; class CallbackEvent extends Event { /** * The callback to call. * * @var string */ protected $callback; /** * The parameters to pass to the method. * * @var array */ protected $parameters; /** * Create a new event instance. * * @param \Illuminate\Console\Scheduling\Mutex $mutex * @param string $callback * @param array $parameters * @return void * * @throws \InvalidArgumentException */ public function __construct(Mutex $mutex, $callback, array $parameters = []) { if (! is_string($callback) && ! is_callable($callback)) { throw new InvalidArgumentException( 'Invalid scheduled callback event. Must be a string or callable.' ); } $this->mutex = $mutex; $this->callback = $callback; $this->parameters = $parameters; } /** * Run the given event. * * @param \Illuminate\Contracts\Container\Container $container * @return mixed * * @throws \Exception */ public function run(Container $container) { if ($this->description && $this->withoutOverlapping && ! $this->mutex->create($this)) { return; } $pid = getmypid(); register_shutdown_function(function () use ($pid) { if ($pid === getmypid()) { $this->removeMutex(); } }); parent::callBeforeCallbacks($container); try { $response = $container->call($this->callback, $this->parameters); } finally { $this->removeMutex(); parent::callAfterCallbacks($container); } return $response; } /** * Clear the mutex for the event. * * @return void */ protected function removeMutex() { if ($this->description) { $this->mutex->forget($this); } } /** * Do not allow the event to overlap each other. * * @param int $expiresAt * @return $this */ public function withoutOverlapping($expiresAt = 1440) { if (! isset($this->description)) { throw new LogicException( "A scheduled event name is required to prevent overlapping. Use the 'name' method before 'withoutOverlapping'." ); } $this->withoutOverlapping = true; $this->expiresAt = $expiresAt; return $this->skip(function () { return $this->mutex->exists($this); }); } /** * Get the mutex name for the scheduled command. * * @return string */ public function mutexName() { return 'framework/schedule-'.sha1($this->description); } /** * Get the summary of the event for display. * * @return string */ public function getSummaryForDisplay() { if (is_string($this->description)) { return $this->description; } return is_string($this->callback) ? $this->callback : 'Closure'; } }