コード例 #1
0
 /**
  * {@inheritdoc}
  */
 protected function process()
 {
     parent::process();
     $self = $this;
     $clear = new ResourceIteratorApplyBatched($this->getResult(), function ($iterator, $batched) use($self) {
         $set = new CommandSet();
         foreach ($batched as $key) {
             $set->addCommand(new PutAcl(array('bucket' => $iterator->getBucketName(), 'acl' => $self->get('acl'))));
         }
         $self->getClient()->execute($set);
     });
     // Set the number of iterated objects
     $clear->apply();
     $this->result = $clear;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 protected function process()
 {
     parent::process();
     $self = $this;
     $clear = new ResourceIteratorApplyBatched($this->getResult(), function ($iterator, $batched) use($self) {
         if (count($batched)) {
             $set = new CommandSet();
             foreach ($batched as $key) {
                 $set->addCommand(new DeleteObject(array('bucket' => $iterator->getBucketName(), 'key' => $key['key'])));
             }
             $self->getClient()->execute($set);
         }
     });
     $clear->apply($this->get('per_batch', 20));
     $this->result = $clear;
 }
コード例 #3
0
ファイル: ClientTest.php プロジェクト: norv/guzzle
 /**
  * @covers Guzzle\Service\Client::execute
  */
 public function testExecutesCommandSets()
 {
     $client = new Client('http://www.test.com/');
     $client->getEventDispatcher()->addSubscriber(new MockPlugin(array(new Response(200))));
     // Create a command set and a command
     $set = new CommandSet();
     $cmd = new MockCommand();
     $set->addCommand($cmd);
     $this->assertSame($set, $client->execute($set));
     // Make sure it sent
     $this->assertTrue($cmd->isExecuted());
     $this->assertTrue($cmd->isPrepared());
     $this->assertEquals(200, $cmd->getResponse()->getStatusCode());
 }