示例#1
0
 /**
  * Get the default chain to use with clients
  *
  * @param ClientInterface $client Client to base the chain on
  *
  * @return self
  */
 public static function getDefaultChain(ClientInterface $client)
 {
     $factories = array();
     if ($description = $client->getDescription()) {
         $factories[] = new ServiceDescriptionFactory($description);
     }
     $factories[] = new ConcreteClassFactory($client);
     return new self($factories);
 }
示例#2
0
 public function factory($name, array $args = array())
 {
     // Determine the class to instantiate based on the namespace of the current client and the default directory
     $prefix = $this->client->getConfig('command.prefix');
     if (!$prefix) {
         // The prefix can be specified in a factory method and is cached
         $prefix = implode('\\', array_slice(explode('\\', get_class($this->client)), 0, -1)) . '\\Command\\';
         $this->client->getConfig()->set('command.prefix', $prefix);
     }
     $class = $prefix . str_replace(' ', '\\', ucwords(str_replace('.', ' ', $this->inflector->camel($name))));
     // Create the concrete command if it exists
     if (class_exists($class)) {
         return new $class($args);
     }
 }