$map
$map : array
Resource iterator factory used when explicitly mapping strings to iterator classes
build(\Guzzle\Service\Command\CommandInterface $command, array $options = array()) : \Guzzle\Service\Resource\ResourceIteratorInterface
Create a resource iterator
\Guzzle\Service\Command\CommandInterface | $command | Command to create an iterator for |
array | $options | Iterator options that are exposed as data. |
canBuild(\Guzzle\Service\Command\CommandInterface $command) : boolean
Check if the factory can create an iterator
\Guzzle\Service\Command\CommandInterface | $command | Command to create an iterator for |
getClassName(\Guzzle\Service\Command\CommandInterface $command) : string
Get the name of the class to instantiate for the command
\Guzzle\Service\Command\CommandInterface | $command | Command that is associated with the iterator |
<?php
namespace Guzzle\Service\Resource;
use Guzzle\Service\Command\CommandInterface;
/**
* Resource iterator factory used when explicitly mapping strings to iterator classes
*/
class MapResourceIteratorFactory extends AbstractResourceIteratorFactory
{
/** @var array Associative array mapping iterator names to class names */
protected $map;
/** @param array $map Associative array mapping iterator names to class names */
public function __construct(array $map)
{
$this->map = $map;
}
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;
}
}