当前位置: 首页>>代码示例>>PHP>>正文


PHP CommandInterface::getOperation方法代码示例

本文整理汇总了PHP中Guzzle\Service\Command\CommandInterface::getOperation方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandInterface::getOperation方法的具体用法?PHP CommandInterface::getOperation怎么用?PHP CommandInterface::getOperation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Service\Command\CommandInterface的用法示例。


在下文中一共展示了CommandInterface::getOperation方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleParsing

 protected function handleParsing(CommandInterface $command, Response $response, $contentType)
 {
     $operation = $command->getOperation();
     $type = $operation->getResponseType();
     $model = null;
     if ($type == OperationInterface::TYPE_MODEL) {
         $model = $operation->getServiceDescription()->getModel($operation->getResponseClass());
     } elseif ($type == OperationInterface::TYPE_CLASS) {
         $responseClassInterface = __NAMESPACE__ . '\\ResponseClassInterface';
         $className = $operation->getResponseClass();
         if (!class_exists($className)) {
             throw new ResponseClassException("{$className} does not exist");
         } elseif (!method_exists($className, 'fromCommand')) {
             throw new ResponseClassException("{$className} must implement {$responseClassInterface}");
         }
         return $className::fromCommand($command);
     }
     if (!$model) {
         // Return basic processing if the responseType is not model or the model cannot be found
         return parent::handleParsing($command, $response, $contentType);
     } elseif ($command[AbstractCommand::RESPONSE_PROCESSING] != AbstractCommand::TYPE_MODEL) {
         // Returns a model with no visiting if the command response processing is not model
         return new Model(parent::handleParsing($command, $response, $contentType), $model);
     } else {
         return new Model($this->visitResult($model, $command, $response), $model);
     }
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:27,代码来源:OperationResponseParser.php

示例2: after

public function after(CommandInterface $command, RequestInterface $request)
{
$xml = null;


 if (isset($this->data[$command])) {
$xml = $this->finishDocument($this->data[$command]);
unset($this->data[$command]);
} else {

 $operation = $command->getOperation();
if ($operation->getData('xmlAllowEmpty')) {
$xmlWriter = $this->createRootElement($operation);
$xml = $this->finishDocument($xmlWriter);
}
}

if ($xml) {

 if ($this->contentType && !$request->hasHeader('Content-Type')) {
$request->setHeader('Content-Type', $this->contentType);
}
$request->setBody($xml);
}
}
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:25,代码来源:XmlVisitor.php

示例3: parseClass

 /**
  * Parse a class object
  *
  * @param CommandInterface $command Command to parse into an object
  *
  * @return mixed
  * @throws ResponseClassException
  */
 protected function parseClass(CommandInterface $command)
 {
     $className = $command->getOperation()->getResponseClass();
     if (!class_exists($className)) {
         throw new ResponseClassException("{$className} does not exist");
     }
     if (!method_exists($className, 'fromCommand')) {
         throw new ResponseClassException("{$className} must implement the fromCommand() method");
     }
     return $className::fromCommand($command);
 }
开发者ID:ebeauchamps,项目名称:brilliantretail,代码行数:19,代码来源:OperationResponseParser.php

示例4: parseClass

 protected function parseClass(CommandInterface $command)
 {
     $event = new CreateResponseClassEvent(array('command' => $command));
     $command->getClient()->getEventDispatcher()->dispatch('command.parse_response', $event);
     if ($result = $event->getResult()) {
         return $result;
     }
     $className = $command->getOperation()->getResponseClass();
     if (!method_exists($className, 'fromCommand')) {
         throw new ResponseClassException("{$className} must exist and implement a static fromCommand() method");
     }
     return $className::fromCommand($command);
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:13,代码来源:OperationResponseParser.php

示例5: 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

示例6: getClassName

 protected function getClassName(CommandInterface $command)
 {
     $iteratorName = $this->inflector->camel($command->getName()) . 'Iterator';
     $iteratorSpecified = $command->getOperation()->getData('iteratorClass');
     // @TODO fix this near duplication
     if (!is_null($iteratorSpecified)) {
         foreach ($this->namespaces as $namespace) {
             $potentialClassName = $namespace . '\\' . $iteratorSpecified;
             if (class_exists($potentialClassName)) {
                 return $potentialClassName;
             }
         }
     }
     foreach ($this->namespaces as $namespace) {
         $potentialClassName = $namespace . '\\' . $iteratorName;
         if (class_exists($potentialClassName)) {
             return $potentialClassName;
         }
     }
     return false;
 }
开发者ID:jyokum,项目名称:healthgraph,代码行数:21,代码来源:HealthGraphIteratorFactory.php

示例7: createRequest

 protected function createRequest(CommandInterface $command)
 {
     $operation = $command->getOperation();
     $client = $command->getClient();
     $options = $command[AbstractCommand::REQUEST_OPTIONS] ?: array();
     if (!($uri = $operation->getUri())) {
         return $client->createRequest($operation->getHttpMethod(), $client->getBaseUrl(), null, null, $options);
     }
     $variables = array();
     foreach ($operation->getParams() as $name => $arg) {
         if ($arg->getLocation() == 'uri') {
             if (isset($command[$name])) {
                 $variables[$name] = $arg->filter($command[$name]);
                 if (!is_array($variables[$name])) {
                     $variables[$name] = (string) $variables[$name];
                 }
             }
         }
     }
     return $client->createRequest($operation->getHttpMethod(), array($uri, $variables), null, null, $options);
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:21,代码来源:DefaultRequestSerializer.php

示例8: after

 public function after(CommandInterface $command, RequestInterface $request)
 {
     $xml = null;
     // If data was found that needs to be serialized, then do so
     if (isset($this->data[$command])) {
         $xml = $this->data[$command]->asXML();
         unset($this->data[$command]);
     } else {
         // Check if XML should always be sent for the command
         $operation = $command->getOperation();
         if ($operation->getData('xmlAllowEmpty')) {
             $xml = $this->createRootElement($operation)->asXML();
         }
     }
     if ($xml) {
         $request->setBody($xml);
         // Don't overwrite the Content-Type if one is set
         if ($this->contentType && !$request->hasHeader('Content-Type')) {
             $request->setHeader('Content-Type', $this->contentType);
         }
     }
 }
开发者ID:creazy412,项目名称:vmware-win10-c65-drupal7,代码行数:22,代码来源:XmlVisitor.php

示例9: 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();
     $options = $command[AbstractCommand::REQUEST_OPTIONS] ?: array();
     // 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(), null, null, $options);
     }
     // Get the path values and use the client config settings
     $variables = array();
     foreach ($operation->getParams() as $name => $arg) {
         if ($arg->getLocation() == 'uri') {
             if (isset($command[$name])) {
                 $variables[$name] = $arg->filter($command[$name]);
                 if (!is_array($variables[$name])) {
                     $variables[$name] = (string) $variables[$name];
                 }
             }
         }
     }
     return $client->createRequest($operation->getHttpMethod(), array($uri, $variables), null, null, $options);
 }
开发者ID:adrianoaguiar,项目名称:magento-elasticsearch-module,代码行数:30,代码来源:DefaultRequestSerializer.php

示例10: 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

示例11: deserialize

 /**
  * Deserialize the response.
  *
  * @param CommandInterface $command     Command.
  * @param Response         $response    Response.
  * @param string           $contentType Content type.
  *
  * @return mixed|null Deserialized response, or `null`.
  */
 protected function deserialize(CommandInterface $command, Response $response, $contentType)
 {
     if ($this->serializer) {
         if (false !== stripos($contentType, 'json')) {
             $serializerContentType = 'json';
         } elseif (false !== stripos($contentType, 'xml')) {
             $serializerContentType = 'xml';
         } else {
             $serializerContentType = null;
         }
         if (null !== $serializerContentType && OperationInterface::TYPE_CLASS === $command->getOperation()->getResponseType()) {
             $context = DeserializationContext::create();
             $operation = $command->getOperation();
             if (null !== ($groups = $operation->getData('jms_serializer.groups'))) {
                 $context->setGroups($groups);
             }
             if (null !== ($version = $operation->getData('jms_serializer.version'))) {
                 $context->setVersion($version);
             }
             if (true === $operation->getData('jms_serializer.max_depth_checks')) {
                 $context->enableMaxDepthChecks();
             }
             return $this->serializer->deserialize($response->getBody(), $command->getOperation()->getResponseClass(), $serializerContentType, $context);
         }
     }
     return null;
 }
开发者ID:aciliainternet,项目名称:guzzle-bundle,代码行数:36,代码来源:JMSSerializerResponseParser.php

示例12: responseTypeIsModel

 /**
  * Determines whether a command's response type is a model
  *
  * @param \Guzzle\Service\Command\AbstractCommand $command
  *
  * @return boolean
  */
 public function responseTypeIsModel(CommandInterface $command)
 {
     if (!$command instanceof AbstractCommand) {
         return false;
     }
     $operation = $command->getOperation();
     $processing = $command->get(AbstractCommand::RESPONSE_PROCESSING);
     $description = $operation->getServiceDescription();
     return $operation->getResponseType() == OperationInterface::TYPE_MODEL && $description->hasModel($operation->getResponseClass()) && $processing == AbstractCommand::TYPE_MODEL;
 }
开发者ID:dh-open,项目名称:desk-php,代码行数:17,代码来源:ResponseParser.php

示例13: getClassName

 /**
  * This is a good extension point if you need something fancier
  *
  * @param GuzzleCommandInterface $command
  *
  * @return string
  */
 protected function getClassName(GuzzleCommandInterface $command)
 {
     return $command->getOperation()->getResponseClass();
 }
开发者ID:uniplaces,项目名称:fastc,代码行数:11,代码来源:ParseResponseListener.php


注:本文中的Guzzle\Service\Command\CommandInterface::getOperation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。