defer() 정적인 공개 메소드

$callable will be executed after the response has been sent to the client. This is useful for expensive operations which do not need to send anything to the client. At the first call to defer, deferring will be "activated". This means that output buffering is enabled, keepalive disabled and user-abort is ignored. You can check to see if deferring is enabled by doing a truth check on gb::$deferred. The event "did-activate-deferring" is also posted. Use deferring wth caution. A good example of when delayed execution is a good idea, is how the email-notification plugin defers the mail action (this is actually part of GBMail but this plugin makes good use of it). Events: - "did-activate-deferring" Posted when defer is activated.
static public defer ( $callable )
예제 #1
0
파일: git.php 프로젝트: rsms/gitblog
 static function commit($message, $author = null, $pathspec = null, $deferred = false)
 {
     # clear status cache
     self::$status_cache = null;
     if ($deferred && gb::defer(array('gb', 'commit'), $message, $author, $pathspec, false)) {
         $pathspec = $pathspec ? r($pathspec) : '';
         gb::log('deferred commit -m %s --author %s %s', escapeshellarg($message), escapeshellarg($author), $pathspec);
         if (!$pathspec) {
             gb::log(LOG_WARNING, 'deferred commits without pathspec might cause unexpected changesets');
         }
         return true;
     }
     if ($pathspec) {
         $pathspec = ' ' . self::escargs($pathspec);
     } else {
         $pathspec = '';
     }
     $author = $author ? '--author=' . escapeshellarg($author) : '';
     git::exec('commit -m ' . escapeshellarg($message) . ' --quiet ' . $author . ' -- ' . $pathspec);
     @chmod(gb::$site_dir . '/.git/COMMIT_EDITMSG', 0664);
     return true;
 }
예제 #2
0
파일: GBMail.php 프로젝트: rsms/gitblog
 /**
  * Send the mail.
  * 
  * $deferred defaults to true if delivery subsystem is SMTP, otherwise
  * default is false (not using delay execution).
  */
 function send($deferred = null)
 {
     if (($deferred === null && $this->mailer->Mailer === 'smtp' || $deferred) && gb::defer(array($this, 'send'), false)) {
         return true;
     }
     $return_value = true;
     $r = $this->rawRecipients();
     $to = array();
     foreach ($r as $addrs) {
         $to = array_filter(array_merge($to, $addrs));
     }
     $to = implode(', ', $to);
     if (!$to) {
         throw new UnexpectedValueException('no recipients specified');
     }
     # from must be set
     if (!$this->mailer->From) {
         list($this->mailer->From, $this->mailer->FromName) = $this->authorizedFromAddress();
     }
     # since PHPMailer is one ugly piece of software
     $orig_error_reporting = error_reporting(E_ALL ^ E_NOTICE);
     gb::log('sending email to %s with subject %s', $to, r($this->mailer->Subject));
     if (!$this->mailer->Send()) {
         gb::log(LOG_ERR, 'failed to send email to %s: %s', $to, $this->mailer->ErrorInfo);
         $return_value = false;
     } else {
         gb::log('sent email to %s with subject %s', $to, r($this->mailer->Subject));
     }
     # reset error reporting
     error_reporting($orig_error_reporting);
     return $return_value;
 }