Пример #1
0
 public function testRemoveClient()
 {
     $services = $this->getServiceManager();
     $services->removeClient('testgroup', 'testservice');
     $services->save();
     $json = file_get_contents('build/test/testgroup.json');
     $data = Json::decode($json);
     $this->assertEmpty($data['services']);
 }
Пример #2
0
 /**
  * @return array
  */
 public function cookie()
 {
     return Json::decode($this['cookie']);
 }
Пример #3
0
 /**
  * @param string $group
  * @param boolean $overwrite
  *
  * @throws \Symfony\Component\Filesystem\Exception\IOException
  *
  * @see http://guzzlephp.org/webservice-client/using-the-service-builder.html#sourcing-from-a-json-document
  */
 public function saveServiceGroup($group, $overwrite = false)
 {
     $filename = $this->getConfigFilename($group);
     $hasConfigFile = $this->hasConfigFile($group);
     // This sucks, but it is the only way to get the builder config.
     // @todo Create a Guzzle issue to add a getBuilderConfig() method.
     $builder = $this[$group];
     $builderConfig = Json::decode($builder->serialize());
     // @todo Add validation.
     if (!$overwrite && $hasConfigFile) {
         $groupJson = file_get_contents($filename);
         $groupData = Json::decode($groupJson);
         $builderConfig = array_merge($groupData['services'], $builderConfig);
     }
     // Unset the services that are flagged to be removed then clear the
     // remove flag since action was taken.
     foreach ($this->removed[$group] as $name) {
         unset($builderConfig[$name]);
     }
     $this->removed[$group] = array();
     $json = Json::encode(array('class' => get_class($builder), 'services' => $builderConfig));
     $filesystem = $this->getFilesystem();
     if (!$hasConfigFile) {
         $filesystem->mkdir(dirname($filename), 0755);
     }
     $filesystem->dumpFile($filename, $json, 0600);
 }