本文整理汇总了PHP中Guzzle\Service\Command\CommandInterface::getClient方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandInterface::getClient方法的具体用法?PHP CommandInterface::getClient怎么用?PHP CommandInterface::getClient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Service\Command\CommandInterface
的用法示例。
在下文中一共展示了CommandInterface::getClient方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createLinkCommand
/**
* {@inheritdoc}
*/
public function createLinkCommand(CommandInterface $command, Parameter $structure, array $data)
{
$this->validateLink($data);
$this->validateLinkStructure($structure);
$operation = $structure->getData('operation');
$pattern = $structure->getData('pattern');
$params = $this->parseHref($data['href'], $pattern);
return $command->getClient()->getCommand($operation, $params);
}
示例2: factory
/**
* {@inheritdoc}
*/
public function factory(CommandInterface $originalCommand, array $data)
{
$command = $this->newCommand();
// set up embedded command
$command->setClient($originalCommand->getClient());
$originalResponse = $originalCommand->getResponse();
$response = $this->createResponse($originalResponse, $data);
$command->setResponse($response);
return $command;
}
示例3: 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);
}
示例4: 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;
}
示例5: 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);
}
示例6: 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);
}
示例7: 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)));
}
示例8: validateScheme
private function validateScheme(CommandInterface $command)
{
if ($command->getClient()->getConfig('scheme') !== 'https') {
throw new RuntimeException('You must configure your S3 client to ' . 'use HTTPS in order to use the SSE-C features.');
}
}