class IoEmittingEntityBody

EntityBody decorator that emits events for read and write methods

Hierarchy

Expanded class hierarchy of IoEmittingEntityBody

File

drupal/core/vendor/guzzle/http/Guzzle/Http/IoEmittingEntityBody.php, line 14

Namespace

Guzzle\Http
View source
class IoEmittingEntityBody extends AbstractEntityBodyDecorator implements HasDispatcherInterface {

  /**
   * @var EventDispatcherInterface
   */
  protected $eventDispatcher;

  /**
   * {@inheritdoc}
   */
  public static function getAllEvents() {
    return array(
      'body.read',
      'body.write',
    );
  }

  /**
   * {@inheritdoc}
   * @codeCoverageIgnore
   */
  public function setEventDispatcher(EventDispatcherInterface $eventDispatcher) {
    $this->eventDispatcher = $eventDispatcher;
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function getEventDispatcher() {
    if (!$this->eventDispatcher) {
      $this->eventDispatcher = new EventDispatcher();
    }
    return $this->eventDispatcher;
  }

  /**
   * {@inheritdoc}
   */
  public function dispatch($eventName, array $context = array()) {
    $this
      ->getEventDispatcher()
      ->dispatch($eventName, new Event($context));
  }

  /**
   * {@inheritdoc}
   * @codeCoverageIgnore
   */
  public function addSubscriber(EventSubscriberInterface $subscriber) {
    $this
      ->getEventDispatcher()
      ->addSubscriber($subscriber);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function read($length) {
    $event = array(
      'body' => $this,
      'length' => $length,
      'read' => $this->body
        ->read($length),
    );
    $this
      ->dispatch('body.read', $event);
    return $event['read'];
  }

  /**
   * {@inheritdoc}
   */
  public function write($string) {
    $event = array(
      'body' => $this,
      'write' => $string,
      'result' => $this->body
        ->write($string),
    );
    $this
      ->dispatch('body.write', $event);
    return $event['result'];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AbstractEntityBodyDecorator::$body protected property
AbstractEntityBodyDecorator::compress public function @codeCoverageIgnore Overrides EntityBodyInterface::compress
AbstractEntityBodyDecorator::ftell public function @codeCoverageIgnore Overrides StreamInterface::ftell
AbstractEntityBodyDecorator::getContentEncoding public function Get the Content-Encoding of the EntityBody Overrides EntityBodyInterface::getContentEncoding
AbstractEntityBodyDecorator::getContentLength public function Get the Content-Length of the entity body if possible (alias of getSize) Overrides EntityBodyInterface::getContentLength 1
AbstractEntityBodyDecorator::getContentMd5 public function Get an MD5 checksum of the stream's contents Overrides EntityBodyInterface::getContentMd5
AbstractEntityBodyDecorator::getContentType public function Guess the Content-Type or return the default application/octet-stream Overrides EntityBodyInterface::getContentType
AbstractEntityBodyDecorator::getMetaData public function @codeCoverageIgnore Overrides StreamInterface::getMetaData
AbstractEntityBodyDecorator::getSize public function Get the size of the stream if able Overrides StreamInterface::getSize
AbstractEntityBodyDecorator::getStream public function Get the stream resource Overrides StreamInterface::getStream
AbstractEntityBodyDecorator::getStreamType public function Get a label describing the underlying implementation of the stream Overrides StreamInterface::getStreamType
AbstractEntityBodyDecorator::getUri public function Get the URI/filename associated with this stream Overrides StreamInterface::getUri
AbstractEntityBodyDecorator::getWrapper public function Get the stream wrapper type Overrides StreamInterface::getWrapper
AbstractEntityBodyDecorator::getWrapperData public function Wrapper specific data attached to this stream. Overrides StreamInterface::getWrapperData
AbstractEntityBodyDecorator::isConsumed public function Check if the stream has been consumed Overrides StreamInterface::isConsumed 1
AbstractEntityBodyDecorator::isLocal public function Check if the stream is a local stream vs a remote stream Overrides StreamInterface::isLocal
AbstractEntityBodyDecorator::isReadable public function Check if the stream is readable Overrides StreamInterface::isReadable
AbstractEntityBodyDecorator::isSeekable public function Check if the string is repeatable Overrides StreamInterface::isSeekable
AbstractEntityBodyDecorator::isWritable public function Check if the stream is writable Overrides StreamInterface::isWritable
AbstractEntityBodyDecorator::rewind public function @codeCoverageIgnore Overrides StreamInterface::rewind
AbstractEntityBodyDecorator::seek public function @codeCoverageIgnore Overrides StreamInterface::seek 1
AbstractEntityBodyDecorator::setRewindFunction public function @codeCoverageIgnore Overrides EntityBodyInterface::setRewindFunction
AbstractEntityBodyDecorator::setSize public function @codeCoverageIgnore Overrides StreamInterface::setSize
AbstractEntityBodyDecorator::setStream public function @codeCoverageIgnore Overrides StreamInterface::setStream
AbstractEntityBodyDecorator::uncompress public function @codeCoverageIgnore Overrides EntityBodyInterface::uncompress
AbstractEntityBodyDecorator::__call public function Allow decorators to implement custom methods
AbstractEntityBodyDecorator::__construct public function Wrap a entity body 1
AbstractEntityBodyDecorator::__toString public function Convert the stream to a string if the stream is readable and the stream is seekable. Overrides StreamInterface::__toString 1
IoEmittingEntityBody::$eventDispatcher protected property
IoEmittingEntityBody::addSubscriber public function @codeCoverageIgnore Overrides HasDispatcherInterface::addSubscriber
IoEmittingEntityBody::dispatch public function Helper to dispatch Guzzle events and set the event name on the event Overrides HasDispatcherInterface::dispatch
IoEmittingEntityBody::getAllEvents public static function Get a list of all of the events emitted from the class Overrides HasDispatcherInterface::getAllEvents
IoEmittingEntityBody::getEventDispatcher public function Get the EventDispatcher of the request Overrides HasDispatcherInterface::getEventDispatcher
IoEmittingEntityBody::read public function @codeCoverageIgnore Overrides AbstractEntityBodyDecorator::read
IoEmittingEntityBody::setEventDispatcher public function @codeCoverageIgnore Overrides HasDispatcherInterface::setEventDispatcher
IoEmittingEntityBody::write public function @codeCoverageIgnore Overrides AbstractEntityBodyDecorator::write