当前位置: 首页>>代码示例>>PHP>>正文


PHP SplSubject::getLastEvent方法代码示例

本文整理汇总了PHP中SplSubject::getLastEvent方法的典型用法代码示例。如果您正苦于以下问题:PHP SplSubject::getLastEvent方法的具体用法?PHP SplSubject::getLastEvent怎么用?PHP SplSubject::getLastEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SplSubject的用法示例。


在下文中一共展示了SplSubject::getLastEvent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update

 public function update(SplSubject $subject)
 {
     $event = $subject->getLastEvent();
     // force a timeout when writing request body
     if ('sentHeaders' == $event['name']) {
         $this->headers = $event['data'];
     }
 }
开发者ID:SuhitNarayan,项目名称:SuhitNarayan-SEMANTICTECH,代码行数:8,代码来源:CommonNetworkTest.php

示例2: update

 public function update(SplSubject $subject)
 {
     /* @var $subject HTTP_Request2 */
     $event = $subject->getLastEvent();
     if ('sentBody' == $event['name']) {
         $this->size = $event['data'];
     }
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:8,代码来源:CurlTest.php

示例3: update

 public function update(SplSubject $subject)
 {
     /* @var $subject HTTP_Request2 */
     $event = $subject->getLastEvent();
     if ($event['name'] !== end($this->sequence) && (empty($this->_watched) || in_array($event['name'], $this->_watched, true))) {
         $this->sequence[] = $event['name'];
     }
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:8,代码来源:CommonNetworkTest.php

示例4: update

 public function update(SplSubject $subject)
 {
     $event = $subject->getLastEvent();
     switch ($event['name']) {
         case 'receivedHeaders':
             $this->fp = @fopen($this->filename, 'wb');
             if (!$this->fp) {
                 throw new Exception("Cannot open target file '{$filename}'");
             }
             break;
         case 'receivedBodyPart':
         case 'receivedEncodedBodyPart':
             fwrite($this->fp, $event['data']);
             break;
         case 'receivedBody':
             fclose($this->fp);
     }
 }
开发者ID:ned3y2k,项目名称:xe-core,代码行数:18,代码来源:Download.php

示例5: update

 /**
  * Saves current chunk to disk each time a body part is received.
  * If the filename is empty, tries to determine it from received headers
  *
  * @throws \TYPO3\CMS\Core\Exception if file can not be opened
  * @throws \UnexpectedValueException if the file name is empty and can not be determined from headers
  * @param \SplSubject|\HTTP_Request2 $request
  * @return void
  */
 public function update(\SplSubject $request)
 {
     $event = $request->getLastEvent();
     switch ($event['name']) {
         case 'receivedHeaders':
             if ($this->targetFilename === '') {
                 $this->determineFilename($request, $event['data']);
             }
             $this->openFile();
             break;
         case 'receivedBodyPart':
         case 'receivedEncodedBodyPart':
             fwrite($this->filePointer, $event['data']);
             break;
         case 'receivedBody':
             $this->closeFile();
             break;
         default:
     }
 }
开发者ID:nicksergio,项目名称:TYPO3v4-Core,代码行数:29,代码来源:Download.php

示例6: update

 /**
  * Called when the request notifies us of an event.
  *
  * @param HTTP_Request2 $subject The HTTP_Request2 instance
  *
  * @return void
  */
 public function update(SplSubject $subject)
 {
     $event = $subject->getLastEvent();
     if (!in_array($event['name'], $this->events)) {
         return;
     }
     switch ($event['name']) {
         case 'connect':
             $this->log('* Connected to ' . $event['data']);
             break;
         case 'sentHeaders':
             $headers = explode("\r\n", $event['data']);
             array_pop($headers);
             foreach ($headers as $header) {
                 $this->log('> ' . $header);
             }
             break;
         case 'sentBodyPart':
             $this->log('> ' . $event['data'] . ' byte(s) sent');
             break;
         case 'receivedHeaders':
             $this->log(sprintf('< HTTP/%s %s %s', $event['data']->getVersion(), $event['data']->getStatus(), $event['data']->getReasonPhrase()));
             $headers = $event['data']->getHeader();
             foreach ($headers as $key => $val) {
                 $this->log('< ' . $key . ': ' . $val);
             }
             $this->log('< ');
             break;
         case 'receivedBody':
             $this->log($event['data']->getBody());
             break;
         case 'disconnect':
             $this->log('* Disconnected');
             break;
     }
 }
开发者ID:rogerwu99,项目名称:punch_bantana,代码行数:43,代码来源:Log.php

示例7: update

 public function update(SplSubject $subject)
 {
     $this->calls++;
     $this->event = $subject->getLastEvent();
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:5,代码来源:ObserverTest.php

示例8: update

 /**
  * Called when the request notifies us of an event.
  *
  * @param SplSubject $request The HTTP_Request2 instance
  *
  * @return void
  * @throws HTTP_Request2_MessageException
  */
 public function update(SplSubject $request)
 {
     /* @var $request HTTP_Request2 */
     $event = $request->getLastEvent();
     $encoded = false;
     /* @var $event['data'] HTTP_Request2_Response */
     switch ($event['name']) {
         case 'receivedHeaders':
             $this->_processingHeader = true;
             $this->_redirect = $event['data']->isRedirect();
             $this->_encoding = strtolower($event['data']->getHeader('content-encoding'));
             $this->_possibleHeader = '';
             break;
         case 'receivedEncodedBodyPart':
             if (!$this->_streamFilter && ($this->_encoding === 'deflate' || $this->_encoding === 'gzip')) {
                 $this->_streamFilter = stream_filter_append($this->_stream, 'zlib.inflate', STREAM_FILTER_WRITE);
             }
             $encoded = true;
             // fall-through is intentional
         // fall-through is intentional
         case 'receivedBodyPart':
             if ($this->_redirect) {
                 break;
             }
             if (!$encoded || !$this->_processingHeader) {
                 $bytes = fwrite($this->_stream, $event['data']);
             } else {
                 $offset = 0;
                 $this->_possibleHeader .= $event['data'];
                 if ('deflate' === $this->_encoding) {
                     if (2 > strlen($this->_possibleHeader)) {
                         break;
                     }
                     $header = unpack('n', substr($this->_possibleHeader, 0, 2));
                     if (0 == $header[1] % 31) {
                         $offset = 2;
                     }
                 } elseif ('gzip' === $this->_encoding) {
                     if (10 > strlen($this->_possibleHeader)) {
                         break;
                     }
                     try {
                         $offset = HTTP_Request2_Response::parseGzipHeader($this->_possibleHeader, false);
                     } catch (HTTP_Request2_MessageException $e) {
                         // need more data?
                         if (false !== strpos($e->getMessage(), 'data too short')) {
                             break;
                         }
                         throw $e;
                     }
                 }
                 $this->_processingHeader = false;
                 $bytes = fwrite($this->_stream, substr($this->_possibleHeader, $offset));
             }
             if (false === $bytes) {
                 throw new HTTP_Request2_MessageException('fwrite failed.');
             }
             if ($this->_maxDownloadSize && ftell($this->_stream) - $this->_startPosition > $this->_maxDownloadSize) {
                 throw new HTTP_Request2_MessageException(sprintf('Body length limit (%d bytes) reached', $this->_maxDownloadSize));
             }
             break;
         case 'receivedBody':
             if ($this->_streamFilter) {
                 stream_filter_remove($this->_streamFilter);
                 $this->_streamFilter = null;
             }
             break;
     }
 }
开发者ID:Geeklog-Core,项目名称:geeklog,代码行数:77,代码来源:UncompressingDownload.php


注:本文中的SplSubject::getLastEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。