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


PHP CommandInterface::hasKey方法代碼示例

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


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

示例1: prepare

 /**
  * {@inheritdoc}
  */
 public function prepare(CommandInterface $command)
 {
     $operation = $command->getOperation();
     $client = $command->getClient();
     $uri = $operation->getUri();
     if (!$uri) {
         $url = $client->getBaseUrl();
     } else {
         // Get the path values and use the client config settings
         $variables = $client->getConfig()->getAll();
         foreach ($operation->getParams() as $name => $arg) {
             if ($arg->getLocation() == 'uri' && $command->hasKey($name)) {
                 $variables[$name] = $command->get($name);
                 if (!is_array($variables[$name])) {
                     $variables[$name] = (string) $variables[$name];
                 }
             }
         }
         // Merge the client's base URL with an expanded URI template
         $url = (string) Url::factory($client->getBaseUrl())->combine(ParserRegistry::getInstance()->getParser('uri_template')->expand($uri, $variables));
     }
     // Inject path and base_url values into the URL
     $request = $client->createRequest($operation->getHttpMethod(), $url);
     // Add arguments to the request using the location attribute
     foreach ($operation->getParams() as $name => $arg) {
         /** @var $arg \Guzzle\Service\Description\Parameter */
         $location = $arg->getLocation();
         // Visit with the associated visitor
         if (isset($this->visitors[$location])) {
             // Ensure that a value has been set for this parameter
             $value = $command->get($name);
             if ($value !== null) {
                 // Apply the parameter value with the location visitor
                 $this->visitors[$location]->visit($command, $request, $arg, $value);
             }
         }
     }
     // Call the after method on each visitor
     foreach ($this->visitors as $visitor) {
         $visitor->after($command, $request);
     }
     return $request;
 }
開發者ID:xkeygmbh,項目名稱:ifresco-php,代碼行數:46,代碼來源:DefaultRequestSerializer.php

示例2: createRequest

 /**
  * Create a request for the command and operation
  *
  * @param CommandInterface $command Command to create a request for
  *
  * @return RequestInterface
  */
 protected function createRequest(CommandInterface $command)
 {
     $operation = $command->getOperation();
     $client = $command->getClient();
     // If the command does not specify a template, then assume the base URL of the client
     if (!($uri = $operation->getUri())) {
         return $client->createRequest($operation->getHttpMethod(), $client->getBaseUrl());
     }
     // Get the path values and use the client config settings
     $variables = array();
     foreach ($operation->getParams() as $name => $arg) {
         if ($arg->getLocation() == 'uri') {
             if ($command->hasKey($name)) {
                 $variables[$name] = $arg->filter($command->get($name));
                 if (!is_array($variables[$name])) {
                     $variables[$name] = (string) $variables[$name];
                 }
             }
         }
     }
     // Merge the client's base URL with an expanded URI template
     return $client->createRequest($operation->getHttpMethod(), (string) Url::factory($client->getBaseUrl())->combine(ParserRegistry::getInstance()->getParser('uri_template')->expand($uri, $variables)));
 }
開發者ID:creazy412,項目名稱:vmware-win10-c65-drupal7,代碼行數:30,代碼來源:DefaultRequestSerializer.php


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