DataSift_Definition::getConsumer PHP Method

getConsumer() public method

Returns a DataSift_StreamConsumer-derived object for this definition, for the given type.
See also: DataSift_StreamConsumer
public getConsumer ( string $type, DataSift_IStreamConsumerEventHandler $eventHandler ) : DataSift_StreamConsumer
$type string The consumer type for which to construct a consumer.
$eventHandler DataSift_IStreamConsumerEventHandler An instance of DataSift_IStreamConsumerEventHandler
return DataSift_StreamConsumer The consumer object.
    public function getConsumer($type, $eventHandler)
    {
        return DataSift_StreamConsumer::factory($this->_user, $type, $this, $eventHandler);
    }

Usage Example

 public function consume($filter)
 {
     // Save the filter
     $this->filter = $filter;
     $definition = new \DataSift_Definition(new \DataSift_User(DATASIFT_USERNAME, DATASIFT_API_KEY), $filter->csdl);
     // Create the consumer
     $consumer = $definition->getConsumer(\DataSift_StreamConsumer::TYPE_HTTP, $this);
     // And start consuming (this will block)
     $consumer->consume();
 }
All Usage Examples Of DataSift_Definition::getConsumer