當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Command\OperationCommand類代碼示例

本文整理匯總了PHP中Guzzle\Service\Command\OperationCommand的典型用法代碼示例。如果您正苦於以下問題:PHP OperationCommand類的具體用法?PHP OperationCommand怎麽用?PHP OperationCommand使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了OperationCommand類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getCommandWithArrayParamAndFilters

 protected function getCommandWithArrayParamAndFilters()
 {
     $operation = new Operation(array('httpMethod' => 'POST', 'parameters' => array('foo' => new Parameter(array('type' => 'string', 'location' => 'query', 'sentAs' => 'Foo', 'required' => true, 'default' => 'bar', 'filters' => array('strtoupper'))), 'arr' => new Parameter(array('type' => 'array', 'location' => 'query', 'sentAs' => 'Arr', 'required' => true, 'default' => array(123, 456, 789), 'filters' => array(array('method' => 'implode', 'args' => array(',', '@value'))))))));
     $command = new OperationCommand(array(), $operation);
     $command->setClient(new MockClient());
     return $command;
 }
開發者ID:Frinstio,項目名稱:AlfredWorkflow.com,代碼行數:7,代碼來源:AbstractVisitorTestCase.php

示例2: fromCommand

 public static function fromCommand(OperationCommand $command)
 {
     $response = json_decode($command->getResponse()->getBody(true), true);
     $class = get_called_class();
     // Cannot do new self() with abstract class
     return new $class($response);
 }
開發者ID:hautelook,項目名稱:rabbitmq-api,代碼行數:7,代碼來源:AbstractRabbitMQModel.php

示例3: fromCommand

 /**
  * The fromCommand method is used by Guzzle to create an instance of this class. It "injects"
  * the response data, which is then parsed to populate this and the associated models.
  *
  * @param Guzzle\Service\Command\OperationCommand
  * @return array
  */
 public static function fromCommand(\Guzzle\Service\Command\OperationCommand $command)
 {
     // Grab the results, which will be in JSON format
     //krumo($command->getResponse());
     $result = $command->getResponse()->json();
     // Start building an array, since a call to the API can include several different sites
     $websites = array();
     // Now iterate through the results
     foreach ($result as $key => $row) {
         // "Target" is a stripped-down version of the URL provided
         $url = $row['target'];
         // Create a new Website model
         $website = new Website($url);
         // The 0 axis holds information about trustworthiness
         if (isset($row[0])) {
             $website->setTrustworthiness($row[0][0], $row[0][1]);
         }
         // The 4 axis contins information pertaining to child satefy
         if (isset($row[4])) {
             $website->setChildSafety($row[4][0], $row[4][1]);
         }
         // NOTE: the axes in indexes 1 and 2 are deprecated.
         // If any categories are specified, set them
         if (isset($row['categories'])) {
             $website->setCategories($row['categories']);
         }
         // If provided, set the blacklist information; we'll discard the timestamp information
         if (isset($row['blacklists'])) {
             $website->setBlacklists(array_keys($row['blacklists']));
         }
         // Add the website
         $websites[$key] = $website;
     }
     return $websites;
 }
開發者ID:lukaswhite,項目名稱:weboftrust,代碼行數:42,代碼來源:ResponseParser.php

示例4: fromCommand

 /**
  * {@inheritdoc}
  */
 public static function fromCommand(OperationCommand $command)
 {
     $data = $command->getResponse()->json();
     $brandAddress = self::hydrateModelProperties(new Address(), $data['agentBrand']['address']);
     $brand = self::hydrateModelProperties(new Brand(), $data['agentBrand'], array(), array('address' => $brandAddress));
     $address = self::hydrateModelProperties(new Address(), $data['address']);
     return self::hydrateModelProperties(new self(), $data, array(), array('address' => $address, 'agentBrand' => $brand));
 }
開發者ID:AlexEvesDeveloper,項目名稱:hl-stuff,代碼行數:11,代碼來源:Agent.php

示例5: testAlreadyOverriddenUserAgent

 public function testAlreadyOverriddenUserAgent()
 {
     $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0) Presto/2.12.388 Version/12.14';
     $command = new OperationCommand();
     $command->set('ua', 'some_value');
     $this->dispatchCommand($command);
     $this->assertSame('some_value', $command->get('ua'));
 }
開發者ID:moriony,項目名稱:ga-measurement-protocol-client,代碼行數:8,代碼來源:UserAgentOverriderTest.php

示例6: fromCommand

 /**
  * {@inheritdoc}
  */
 public static function fromCommand(OperationCommand $command)
 {
     $activities = new Collection();
     foreach ($command->getResponse()->json() as $key => $activity) {
         $activities->add($key, self::hydrateModelProperties(new self(), $activity));
     }
     return $activities;
 }
開發者ID:AlexEvesDeveloper,項目名稱:hl-stuff,代碼行數:11,代碼來源:Activity.php

示例7: fromCommand

 /**
  * {@inheritdoc}
  */
 public static function fromCommand(OperationCommand $command)
 {
     $items = new Collection();
     foreach ($command->getResponse()->json() as $key => $item) {
         $items[$key] = self::hydrateModelProperties(new self(), $item, array('address1' => 'addressLineOne', 'address2' => 'addressLineTwo', 'address3' => 'addressLineThree', 'address4' => 'addressLineFour', 'address5' => 'addressLineFive'));
     }
     return $items;
 }
開發者ID:AlexEvesDeveloper,項目名稱:hl-stuff,代碼行數:11,代碼來源:PafAddress.php

示例8: fromCommand

 public static function fromCommand(OperationCommand $command)
 {
     $xml = $command->getResponse()->xml();
     if (!isset($xml->AuthInfo)) {
         throw new AuthenticationException((string) $xml, $xml->attributes()['errorcode']);
     }
     $authToken = (string) $xml->AuthInfo->attributes()['authToken'];
     return $authToken;
 }
開發者ID:isometriks,項目名稱:galves-api,代碼行數:9,代碼來源:AuthenticateDealer.php

示例9: testAddsContentTypeWhenExpectsIsSetOnCommand

 public function testAddsContentTypeWhenExpectsIsSetOnCommand()
 {
     $op = new OperationCommand(array(), new Operation());
     $op['command.expects'] = 'application/json';
     $op->setClient(new Client());
     $request = $op->prepare();
     $request->setResponse(new Response(200, null, '{"Baz":"Bar"}'), true);
     $this->assertEquals(array('Baz' => 'Bar'), $op->execute());
 }
開發者ID:Frinstio,項目名稱:AlfredWorkflow.com,代碼行數:9,代碼來源:DefaultResponseParserTest.php

示例10: fromCommand

 /**
  * Create a response model object from a completed command.
  *
  * @param OperationCommand $command That serialized the request
  * @return \Illuminate\Support\Collection
  */
 public static function fromCommand(OperationCommand $command)
 {
     // Initialize the collection
     $collection = new self($command->getResponse()->json());
     // Set the Usergrid API client on the collection
     $collection->setApiClient($command->getClient()->getApiClient());
     // Return the collection
     return $collection;
 }
開發者ID:rodsimpson,項目名稱:incubator-usergrid,代碼行數:15,代碼來源:GuzzleCommandTrait.php

示例11: fromCommand

 public static function fromCommand(OperationCommand $command)
 {
     $response = $command->getResponse();
     $info = $response->getInfo();
     if ($info['content_type'] === 'image/png' || $info['content_type'] === 'image/jpg') {
         return new static(['logo' => $info['url']]);
     }
     throw new BadResponseException('Content type invalid. API returned ' . $info['content_type']);
 }
開發者ID:karllhughes,項目名稱:clearbit-php,代碼行數:9,代碼來源:Logo.php

示例12: testCastPrimitivesToArrays

 /**
  * @covers Desk\Command\PreValidator::castPrimitivesToArrays
  * @dataProvider dataCastPrimitivesToArrays
  *
  * @param array $param    Parameter description/structure
  * @param mixed $value    Input value for the parameter
  * @param mixed $expected Expected output value
  */
 public function testCastPrimitivesToArrays(array $param, $value, $expected)
 {
     $command = new OperationCommand(array('foo' => $value), new Operation(array('parameters' => array('foo' => $param))));
     $command->setClient(new Client());
     $event = new Event(array('command' => $command));
     $preValidator = $this->mock('castPrimitivesToArrays');
     $preValidator->castPrimitivesToArrays($event);
     $this->assertSame($expected, $command->get('foo'));
 }
開發者ID:dh-open,項目名稱:desk-php,代碼行數:17,代碼來源:PreValidatorTest.php

示例13: testAllowsRawResponses

 public function testAllowsRawResponses()
 {
     $description = new ServiceDescription(array('operations' => array('foo' => array('responseClass' => 'bar', 'responseType' => 'model')), 'models' => array('bar' => array())));
     $op = new OperationCommand(array(OperationCommand::RESPONSE_PROCESSING => OperationCommand::TYPE_RAW), $description->getOperation('foo'));
     $op->setClient(new Client());
     $request = $op->prepare();
     $response = new Response(200, array('Content-Type' => 'application/xml'), '<Foo><Baz>Bar</Baz></Foo>');
     $request->setResponse($response, true);
     $this->assertSame($response, $op->execute());
 }
開發者ID:jorjoh,項目名稱:Varden,代碼行數:10,代碼來源:OperationCommandTest.php

示例14: testSkipsUnkownModels

 public function testSkipsUnkownModels()
 {
     $parser = new OperationResponseParser();
     $operation = $this->getDescription()->getOperation('test');
     $operation->setResponseClass('Baz')->setResponseType('model');
     $op = new OperationCommand(array(), $operation);
     $op->setResponseParser($parser)->setClient(new Client());
     $op->prepare()->setResponse(new Response(201), true);
     $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $op->execute());
 }
開發者ID:xkeygmbh,項目名稱:ifresco-php,代碼行數:10,代碼來源:OperationResponseParserTest.php

示例15: fromCommand

 /**
  * Create a response model object from a completed command
  *
  * @param OperationCommand $command That serialized the request
  *
  * @return CurrencyCollection
  */
 public static function fromCommand(OperationCommand $command)
 {
     $response = $command->getResponse();
     $json = $response->json();
     $currencies = array();
     foreach ($json as $currency) {
         $currencies[] = new Currency($currency['code'], $currency['name'], $currency['rate']);
     }
     return new self($currencies);
 }
開發者ID:symm,項目名稱:guzzle-bitpay,代碼行數:17,代碼來源:CurrencyCollection.php


注:本文中的Guzzle\Service\Command\OperationCommand類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。