示例#1
0
 public function visit(CommandInterface $command, RequestInterface $request, Parameter $param, $value)
 {
     $this->fqname = $command->getName();
     $query = array();
     $this->customResolver($value, $param, $query, $param->getWireName());
     $request->addPostFields($query);
 }
示例#2
0
/**
 * Allows modules to alter an S3 command after it has been created.
 *
 * @param \Guzzle\Service\Command\CommandInterface $command
 *   The command that was created.
 */
function hook_amazons3_command_alter(\Guzzle\Service\Command\CommandInterface $command)
{
    if ($command->getName('HeadObject')) {
        $command->setOnComplete(function () {
            watchdog('amazons3', 'HeadObject was called.');
        });
    }
}
 /**
  * Create a resource iterator
  *
  * @param CommandInterface $data    Command used for building the iterator
  * @param array            $options Iterator options.
  *
  * @return ResourceIteratorInterface
  */
 public function build($data, array $options = null)
 {
     if (!$data instanceof CommandInterface) {
         throw new InvalidArgumentException('The first argument must be an ' . 'instance of CommandInterface');
     }
     // Determine the name of the class to load
     $className = $this->baseNamespace . '\\' . Inflector::camel($data->getName()) . 'Iterator';
     return new $className($data, $options);
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 protected function getClassName(CommandInterface $command)
 {
     // If it's a ListWidgets command, we can iterate over it
     if (preg_match('/^List[A-Za-z]+/', $command->getName())) {
         return $this->iteratorClassName;
     }
     // Otherwise, we don't know how to iterate over that command
     return null;
 }
 public function getClassName(CommandInterface $command)
 {
     $className = $command->getName();
     if (isset($this->map[$className])) {
         return $this->map[$className];
     } elseif (isset($this->map['*'])) {
         return $this->map['*'];
     }
     return null;
 }
 protected function getClassName(CommandInterface $command)
 {
     $iteratorName = $this->inflector->camel($command->getName()) . 'Iterator';
     foreach ($this->namespaces as $namespace) {
         $potentialClassName = $namespace . '\\' . $iteratorName;
         if (class_exists($potentialClassName)) {
             return $potentialClassName;
         }
     }
     return false;
 }
 public function getClassName(CommandInterface $command)
 {
     $className = $command->getName();
     if (isset($this->map[$className])) {
         return $this->map[$className];
     } elseif (isset($this->map['*'])) {
         // If a wildcard was added, then always use that
         return $this->map['*'];
     }
     return null;
 }
 /**
  * {@inheritdoc}
  */
 public function build(CommandInterface $command, array $options = array())
 {
     // Get the configuration data for the command
     $commandName = $command->getName();
     $iteratorConfig = $this->operations->get($commandName) ?: array();
     $options = array_replace($this->config->getAll(), $iteratorConfig, $options);
     // Instantiate the iterator using the primary factory (if there is one)
     if ($this->primaryIteratorFactory && $this->primaryIteratorFactory->canBuild($command)) {
         $iterator = $this->primaryIteratorFactory->build($command, $options);
     } elseif (!$this->operations->hasKey($commandName)) {
         throw new InvalidArgumentException("Iterator was not found for {$commandName}.");
     } else {
         // Fallback to this factory for creating the iterator if the primary factory did not work
         $iterator = new AwsResourceIterator($command, $options);
     }
     return $iterator;
 }
 public function build(CommandInterface $command, array $options = array())
 {
     // Get the configuration data for the command
     $commandName = $command->getName();
     $commandSupported = isset($this->config[$commandName]);
     $options = $this->translateLegacyConfigOptions($options);
     $options += $commandSupported ? $this->config[$commandName] : array();
     // Instantiate the iterator using the primary factory (if one was provided)
     if ($this->primaryIteratorFactory && $this->primaryIteratorFactory->canBuild($command)) {
         $iterator = $this->primaryIteratorFactory->build($command, $options);
     } elseif (!$commandSupported) {
         throw new InvalidArgumentException("Iterator was not found for {$commandName}.");
     } else {
         // Instantiate a generic AWS resource iterator
         $iterator = new MssResourceIterator($command, $options);
     }
     return $iterator;
 }
 /**
  * Create a resource iterator
  *
  * @param CommandInterface $data    Command used for building the iterator
  * @param array            $options Iterator options that are exposed as data.
  *
  * @return ResourceIteratorInterface
  */
 public function build($data, array $options = array())
 {
     if (!$data instanceof CommandInterface) {
         throw new InvalidArgumentException('The first argument must be an instance of CommandInterface');
     }
     $iteratorName = $this->inflector->camel($data->getName()) . 'Iterator';
     // Determine the name of the class to load
     $className = null;
     foreach ($this->namespaces as $namespace) {
         $potentialClassName = $namespace . '\\' . $iteratorName;
         if (class_exists($potentialClassName)) {
             $className = $potentialClassName;
             break;
         }
     }
     if (!$className) {
         throw new InvalidArgumentException("Iterator was not found matching {$iteratorName}");
     }
     return new $className($data, $options);
 }
 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;
 }