Daily laravel-20160712| Schedule

Source: Internet
Author: User

<?phpnamespace Illuminate\Console\Scheduling;use Symfony\Component\Process\ProcessUtils;use  symfony\component\process\phpexecutablefinder;// use namespace.class schedule{     /**     * All of the events on the  schedule.     *     *  @var  array      */    protected  $events  = [];// events schedule  Array set to store the events   // by the way, all  of this is function or instance of class    /**      * Add a new callback event to the  schedule.     *     *  @param   string    $callback &NBSP;&NBSP;&Nbsp;  *  @param   array    $parameters      *   @return  \Illuminate\Console\Scheduling\Event     */     public function call ($callback, array  $parameters  = [])      {         $this->events[] =  $event  = new  callbackevent ($callback,  $parameters);         return $ Event;    }// get a instance about the event function  ,and add it to the events array.    /**      * Add a new Artisan command event to the  schedule.     *     *  @param   string    $command      *  @param   array   $parameters      *  @return  \Illuminate\Console\Scheduling\Event     */    public  Function command ($command, array  $parameters  = [])     {          $binary  = processutils::escapeargument (new  Phpexecutablefinder)->find (false));        // change argument         if  (Defined (' hhvm_version '))  {              $binary  .=  '  --php ';         }        if  (defined (' Artisan_ BINARY '))  {             $artisan  =  Processutils::escapeargument (artisan_binary);        } else {              $artisan  =  ' artisan ';         }         return  $this->exec ("{$binary} {$artisan} {$ command} ",  $parameters);     }// the author said this is  a new artisan command   // suport the HHVM ,good     /**     * add a new command event to  the schedule.     *     *  @param    string   $command      *  @param   array   $parameters      *  @return  \Illuminate\Console\Scheduling\Event      */ &nbsP;  public function exec ($command, array  $parameters  = [])      {        if  (Count ($parameters))  {              $command  .=  '   '. $this Compileparameters ($parameters);        }// prepare the  command.         $this->events[] =  $event  = new  event ($command);// add the instance to the compileparameters         return  $event;     }// add a new  command event to the schedule    /**      * Compile parameters for a command.     *      *  @param   array   $parameters      *  @return  string      */    protected function compileparameters (array $ Parameters)     {        return collect ($ Parameters)->map (function  ($value,  $key)  {             return is_numeric ($key)  ?  $value  :  $key. ' = '. (Is_numeric ($value)  ?  $value  : processutils::escapeargument ($value));         })->implode ('   ');    }// compile or  change the parameters for you want.    /**      * Get all of the events on the schedule.      *     *  @reTurn array     */    public function events ()     {        return  $this->events;     }// big _get    /**     * get  all of the events on the schedule that are due.      *     *  @param   \illuminate\contracts\foundation\ application   $app      *  @return  array      */    public function dueevents ($app)     {         return array_filter ($this->events, function  ($event)  use  ($app)  {            return   $event->isdue ($app);        });     }// a super big _get  function   // this can get all the events on the  schedule that are due.}  at last ,this is a events schedule, that be set  Bigset get bigget and change the params


This article is from the "Focus on PHP" blog, please be sure to keep this source http://jingshanls.blog.51cto.com/3357095/1763266

Daily laravel-20160712| Schedule

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.