Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding an addRequest method to the BatchQueuePlugin. Fixing a docbloc…

…k for CurlMulti
  • Loading branch information...
commit 8a2e98bdf723cae149fa4fcb38b22e17993f223f 1 parent 15be8da
@mtdowling mtdowling authored
Showing with 23 additions and 4 deletions.
  1. +7 −1 Curl/CurlMulti.php
  2. +16 −3 Plugin/BatchQueuePlugin.php
View
8 Curl/CurlMulti.php
@@ -145,12 +145,18 @@ public function __destruct()
}
/**
+ * {@inheritdoc}
+ *
* Adds a request to the next scope (or batch or requests to be sent). If
* a request is added using async, then the request is added to the current
* scope. This means that the request will be sent and polled if requests
* are currently being sent, or that the request will be sent in the next
* send operation.
- * {@inheritdoc}
+ *
+ * @param RequestInterface $request Request to add
+ * @param bool $async (optional) Set to TRUE to add to the current scope
+ *
+ * @return CurlMutli
*/
public function add(RequestInterface $request, $async = false)
{
View
19 Plugin/BatchQueuePlugin.php
@@ -7,7 +7,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
- * Queues requests and sends them in parallel when a flush event is recevied.
+ * Queues requests and sends them in parallel when a flush event is recievied.
* You can call the flush() method on the plugin or emit a 'flush' event from
* the client on which the plugin is attached.
*
@@ -66,7 +66,6 @@ public function removeRequest(RequestInterface $request)
return $this;
}
-
/**
* Add request to the queue
*
@@ -74,10 +73,24 @@ public function removeRequest(RequestInterface $request)
*/
public function onRequestCreate(Event $event)
{
- $this->queue[] = $event['request'];
+ $this->addRequest($event['request']);
+ }
+
+ /**
+ * Add request to the queue
+ *
+ * @param RequestInterface $request Request to add
+ *
+ * @return BatchQueuePlugin
+ */
+ public function addRequest(RequestInterface $request)
+ {
+ $this->queue[] = $request;
if ($this->autoFlushCount && count($this->queue) >= $this->autoFlushCount) {
$this->flush();
}
+
+ return $this;
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.