Beispiel #1
0
 /**
  * Filter data.
  * This method is called whenever data is read from or written to the attach
  * stream.
  *
  * @param   resource  $in           A resource pointing to a bucket brigade
  *                                  which contains one or more bucket
  *                                  objects containing data to be filtered.
  * @param   resource  $out          A resource pointing to a second bucket
  *                                  brigade into which your modified buckets
  *                                  should be replaced.
  * @param   int       &$consumed    Which must always be declared by
  *                                  reference, should be incremented by the
  *                                  length of the data which your filter
  *                                  reads in and alters.
  * @param   bool      $closing      If the stream is in the process of
  *                                  closing (and therefore this is the last
  *                                  pass through the filterchain), the
  *                                  closing parameter will be set to true.
  * @return  int
  */
 public function filter($in, $out, &$consumed, $closing)
 {
     $return = self::FEED_ME;
     $iBucket = new Stream\Bucket($in);
     while (false === $iBucket->eob()) {
         $this->_buffer .= $iBucket->getData();
         $consumed += $iBucket->getLength();
     }
     if (null !== $consumed) {
         $return = self::PASS_ON;
     }
     if (true === $closing) {
         $stream = $this->getStream();
         $this->compute();
         $bucket = new Stream\Bucket($stream, Stream\Bucket::IS_A_STREAM, $this->_buffer);
         $oBucket = new Stream\Bucket($out);
         $oBucket->append($bucket);
         $return = self::PASS_ON;
         $this->_buffer = null;
     }
     return $return;
 }
Beispiel #2
0
 /**
  * Filter data.
  * This method is called whenever data is read from or written to the attach
  * stream.
  *
  * @param   resource  $in           A resource pointing to a bucket brigade
  *                                  which contains one or more bucket
  *                                  objects containing data to be filtered.
  * @param   resource  $out          A resource pointing to a second bucket
  *                                  brigade into which your modified buckets
  *                                  should be replaced.
  * @param   int       &$consumed    Which must always be declared by
  *                                  reference, should be incremented by the
  *                                  length of the data which your filter
  *                                  reads in and alters.
  * @param   bool      $closing      If the stream is in the process of
  *                                  closing (and therefore this is the last
  *                                  pass through the filterchain), the
  *                                  closing parameter will be set to true.
  * @return  int
  */
 public function filter($in, $out, &$consumed, $closing)
 {
     $iBucket = new Stream\Bucket($in);
     $oBucket = new Stream\Bucket($out);
     while (false === $iBucket->eob()) {
         $consumed += $iBucket->getLength();
         $oBucket->append($iBucket);
     }
     unset($iBucket);
     unset($oBucket);
     return self::PASS_ON;
 }