每天laravel-20160711|Event-2
来源:互联网 发布:云杉网络 营收 编辑:程序博客网 时间:2024/06/06 15:15
// 2016-04-11 /* Determine if the filters pass for the event. * * @param \Illuminate\Contracts\Foundation\Application $app * @return bool */ public function filtersPass($app) { foreach ($this->filters as $callback) { if (! $app->call($callback)) { return false; } }// big call for foreach ($this->rejects as $callback) { if ($app->call($callback)) { return false; } }// another big call return true; }// Determine if the filters pass for the event /** * Determine if the event runs in the given environment. * * @param string $environment * @return bool */ public function runsInEnvironment($environment) { return empty($this->environments) || in_array($environment, $this->environments); }// Determine if the event runs in the given environment. /** * Determine if the event runs in maintenance mode. * * @return bool */ public function runsInMaintenanceMode() { return $this->evenInMaintenanceMode; }//Determine if the event runs in maintenance mode // like keep run mode // check of set /** * The Cron expression representing the event's frequency. * * @param string $expression * @return $this */ public function cron($expression) { $this->expression = $expression; return $this; }// The Cron expression representing the event's frequency. // The plan stand for , how many times to the event's run /** * Schedule the event to run hourly. * * @return $this */ public function hourly() { return $this->cron('0 * * * * *'); }// Schedule the event to run hourly // a way to set the expression frequency /** * Schedule the event to run daily. * * @return $this */ public function daily() { return $this->cron('0 0 * * * *'); }// Schedule the event to run daily /** * Schedule the command at a given time. * * @param string $time * @return $this */ public function at($time) { return $this->dailyAt($time); }// Schedule the command at a given time. /** * Schedule the event to run daily at a given time (10:00, 19:30, etc). * * @param string $time * @return $this */ public function dailyAt($time) { $segments = explode(':', $time); return $this->spliceIntoPosition(2, (int) $segments[0]) ->spliceIntoPosition(1, count($segments) == 2 ? (int) $segments[1] : '0'); }// Schedule the event to run daily at a given time (10:00, 19:30,etc) // change time string to time format. /** * Schedule the event to run twice daily. * * @param int $first * @param int $second * @return $this */ public function twiceDaily($first = 1, $second = 13) { $hours = $first.','.$second; return $this->spliceIntoPosition(1, 0) ->spliceIntoPosition(2, $hours); }// just set the string to the time format /** * Schedule the event to run only on weekdays. * * @return $this */ public function weekdays() { return $this->spliceIntoPosition(5, '1-5'); }// Schedule the event to run only on weekdays. // on weekdays. /** * Schedule the event to run only on Mondays. * * @return $this */ public function mondays() { return $this->days(1); }// on Mondays /** * Schedule the event to run only on Tuesdays. * * @return $this */ public function tuesdays() { return $this->days(2); }// on Tuesdays /** * Schedule the event to run only on Wednesdays. * * @return $this */ public function wednesdays() { return $this->days(3); }// Wednesdays /** * Schedule the event to run only on Thursdays. * * @return $this */ public function thursdays() { return $this->days(4); }// Tursdays /** * Schedule the event to run only on Fridays. * * @return $this */ public function fridays() { return $this->days(5); }// fridays /** * Schedule the event to run only on Saturdays. * * @return $this */ public function saturdays() { return $this->days(6); }// saturdays /** * Schedule the event to run only on Sundays. * * @return $this */ public function sundays() { return $this->days(0); }// Sundays /** * Schedule the event to run weekly. * * @return $this */ public function weekly() { return $this->cron('0 0 * * 0 *'); }// weekly time /** * Schedule the event to run weekly on a given day and time. * * @param int $day * @param string $time * @return $this */ public function weeklyOn($day, $time = '0:0') { $this->dailyAt($time); return $this->spliceIntoPosition(5, $day); }// set event run the weely on /** * Schedule the event to run monthly. * * @return $this */ public function monthly() { return $this->cron('0 0 1 * * *'); }// run at monthly. /** * Schedule the event to run quarterly. * * @return $this */ public function quarterly() { return $this->cron('0 0 1 */3 *'); }// run on quarterly /** * Schedule the event to run yearly. * * @return $this */ public function yearly() { return $this->cron('0 0 1 1 * *'); }// run yearly /** * Schedule the event to run every minute. * * @return $this */ public function everyMinute() { return $this->cron('* * * * * *'); }// run minute /** * Schedule the event to run every five minutes. * * @return $this */ public function everyFiveMinutes() { return $this->cron('*/5 * * * * *'); }// every five minutes. /** * Schedule the event to run every ten minutes. * * @return $this */ public function everyTenMinutes() { return $this->cron('*/10 * * * * *'); }// every Ten minutes /** * Schedule the event to run every thirty minutes. * * @return $this */ public function everyThirtyMinutes() { return $this->cron('0,30 * * * * *'); }// every thirty minutes /** * Set the days of the week the command should run on. * * @param array|mixed $days * @return $this */ public function days($days) { $days = is_array($days) ? $days : func_get_args(); return $this->spliceIntoPosition(5, implode(',', $days)); }// Set the days of the week the command should run on. // has a way to get all variable function is func_get_args() // change the string to you want /** * Set the timezone the date should be evaluated on. * * @param \DateTimeZone|string $timezone * @return $this */ public function timezone($timezone) { $this->timezone = $timezone; return $this; }// set time use "this" mode a big set /** * Set which user the command should run as. * * @param string $user * @return $this */ public function user($user) { $this->user = $user; return $this; }// Set which user the command should run as. /** * Limit the environments the command should run in. * * @param array|mixed $environments * @return $this */ public function environments($environments) { $this->environments = is_array($environments) ? $environments : func_get_args(); return $this; }// limit the environments the command should run in. /** * State that the command should run even in maintenance mode. * * @return $this */ public function evenInMaintenanceMode() { $this->evenInMaintenanceMode = true; return $this; }// set a flag about the event mode, its in the maintenance /** * Do not allow the event to overlap each other. * * @return $this */ public function withoutOverlapping() { $this->withoutOverlapping = true; return $this->skip(function () { return file_exists($this->mutexPath()); }); }// Do not allow the event to overlap each other. /** * Register a callback to further filter the schedule. * * @param \Closure $callback * @return $this */ public function when(Closure $callback) { $this->filters[] = $callback; return $this; }// Register a callback to further filter the schedule. /** * Register a callback to further filter the schedule. * * @param \Closure $callback * @return $this */ public function skip(Closure $callback) { $this->rejects[] = $callback; return $this; }// set the rejects to further filter the schedule. /** * Send the output of the command to a given location. * * @param string $location * @param bool $append * @return $this */ public function sendOutputTo($location, $append = false) { $this->output = $location; $this->shouldAppendOutput = $append; return $this; }// set the output of the command to a given location. /** * Append the output of the command to a given location. * * @param string $location * @return $this */ public function appendOutputTo($location) { return $this->sendOutputTo($location, true); }// Append the output of the command to a given location. // use api method /** * E-mail the results of the scheduled operation. * * @param array|mixed $addresses * @param bool $onlyIfOutputExists * @return $this * * @throws \LogicException */ public function emailOutputTo($addresses, $onlyIfOutputExists = false) { if (is_null($this->output) || $this->output == $this->getDefaultOutput()) { throw new LogicException('Must direct output to a file in order to e-mail results.'); }// check the logicException $addresses = is_array($addresses) ? $addresses : func_get_args();// get args return $this->then(function (Mailer $mailer) use ($addresses, $onlyIfOutputExists) { $this->emailOutput($mailer, $addresses, $onlyIfOutputExists); });// get the right way to send a email }// send out in email /** * E-mail the results of the scheduled operation if it produces output. * * @param array|mixed $addresses * @return $this * * @throws \LogicException */ public function emailWrittenOutputTo($addresses) { return $this->emailOutputTo($addresses, true); }// Email the results of the scheduled operation if it produces output. /** * E-mail the output of the event to the recipients. * * @param \Illuminate\Contracts\Mail\Mailer $mailer * @param array $addresses * @param bool $includeEmpty * @return void */ protected function emailOutput(Mailer $mailer, $addresses, $onlyIfOutputExists = false) { $text = file_get_contents($this->output); if ($onlyIfOutputExists && empty($text)) { return; } $mailer->raw($text, function ($m) use ($addresses) { $m->subject($this->getEmailSubject()); foreach ($addresses as $address) { $m->to($address); } }); }//Email the output to get the recipients person. /** * Get the e-mail subject line for output results. * * @return string */ protected function getEmailSubject() { if ($this->description) { return 'Scheduled Job Output ('.$this->description.')'; } return 'Scheduled Job Output'; }// get the send email result , get the result about /** * Register a callback to ping a given URL before the job runs. * * @param string $url * @return $this */ public function pingBefore($url) { return $this->before(function () use ($url) { (new HttpClient)->get($url); }); }// register a callback to ping a given URL before the job runs. /** * Register a callback to be called before the operation. * * @param \Closure $callback * @return $this */ public function before(Closure $callback) { $this->beforeCallbacks[] = $callback; return $this; }// Register a callback to be called before the operation. /** * Register a callback to ping a given URL after the job runs. * * @param string $url * @return $this */ public function thenPing($url) { return $this->then(function () use ($url) { (new HttpClient)->get($url); }); }// Register a call /** * Register a callback to be called after the operation. * * @param \Closure $callback * @return $this */ public function after(Closure $callback) { return $this->then($callback); }// api /** * Register a callback to be called after the operation. * * @param \Closure $callback * @return $this */ public function then(Closure $callback) { $this->afterCallbacks[] = $callback; return $this; }// set array store /** * Set the human-friendly description of the event. * * @param string $description * @return $this */ public function name($description) { return $this->description($description); }// set the human-friendly description of the event. /** * Set the human-friendly description of the event. * * @param string $description * @return $this */ public function description($description) { $this->description = $description; return $this; }//set description /** * Splice the given value into the given position of the expression. * * @param int $position * @param string $value * @return $this */ protected function spliceIntoPosition($position, $value) { $segments = explode(' ', $this->expression); $segments[$position - 1] = $value; return $this->cron(implode(' ', $segments)); }// set format /** * Get the summary of the event for display. * * @return string */ public function getSummaryForDisplay() { if (is_string($this->description)) { return $this->description; } return $this->buildCommand(); }// the the description /** * Get the Cron expression for the event. * * @return string */ public function getExpression() { return $this->expression; }// get E}
0 0
- 每天laravel-20160711|Event-2
- 每天laravel-20160710|Event
- 每天laravel-20160718|Command-2
- 每天laravel-20160722|Application-2
- 每天laravel-20160730| Container -2
- 每天laravel-20160822|CookieJar-2
- 每天laravel
- 每天laravel-20160725| Genaerator command-2
- [李景山php]每天laravel-20160828|McryptEncrypter-2
- [李景山php]每天laravel-20160902|Dispatcher-2
- [李景山php]每天laravel-20160911|FileSystem-2
- [李景山php]每天laravel-20160915|FileSystemManager-2
- [李景山php]每天laravel-20160920|Writer-2
- laravel Event事件
- Laravel事件 event
- Laravel事件Event
- laravel event事件 讲解
- laravel Event执行顺序
- ping 127.0.0.1可以ping通,但是ping本机ip地址不通
- maven读取顺序
- 码农小汪-spring框架学习之8- Using JSR 330 Standard Annotations @Inject and @Named
- 已知经纬度求地球上两地点之间球面距离
- Android属性allowBackup安全风险浅析
- 每天laravel-20160711|Event-2
- 数据库中以年/月/日为单位查询数量
- maven坐标
- 转载_快速理解Docker - 容器级虚拟化解决方案
- stm32 学习之初体验 KEY control BEEP
- ConcurrentHashMap
- 霍夫变换检测直线
- JavaScript语言精粹之数组篇
- javascript——js string 转 int 注意的问题——parseInt