コード例 #1
0
 /**
  * @expectedException \OutOfBoundsException
  */
 public function testNestedCollectionNotFound()
 {
     $data = array('invalidProperty' => array(array('name' => 'value1')));
     $response = new \Guzzle\Http\Message\Response(200);
     $response->setBody(Json::encode($data));
     $mock = new \Guzzle\Plugin\Mock\MockPlugin();
     $mock->addResponse($response);
     $client = new Client('http://example.com');
     $client->addSubscriber($mock);
     $request = $client->get('/test');
     $collection = new DummyCollection($request);
     foreach ($collection as $element) {
         // We should never get here ...
     }
 }
コード例 #2
0
 /**
  * @return array
  *
  * @throws \RuntimeException
  */
 public function serviceCredentials()
 {
     if (!isset($this->creds)) {
         $filepath = $this->getCredentialsFilepath();
         $this->creds = Json::parseFile($filepath);
     }
     return $this->creds;
 }
コード例 #3
0
ファイル: Task.php プロジェクト: caxy/acquia-sdk-php
 /**
  * @return array
  */
 public function cookie()
 {
     return Json::decode($this['cookie']);
 }
コード例 #4
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']);
 }
コード例 #5
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);
 }
コード例 #6
0
 /**
  * Moves domains atomically from one environment to another.
  *
  * @param string $site
  *   The site.
  * @param string|array $domains
  *   The domain name(s) as an array of strings, or the string '*' to move all
  *   domains.
  * @param string $sourceEnv
  *   The environment which currently has this domain.
  * @param string $targetEnv
  *   The destination environment for the domain.
  * @param bool $skipSiteUpdate
  *   Optional. If set to TRUE this will inhibit running
  *   fields-config-web.php for this domain move.
  *
  * @return \Acquia\Cloud\Api\Response\Task
  *
  * @throws \Guzzle\Http\Exception\ClientErrorResponseException
  *
  * @see http://cloudapi.acquia.com/#POST__sites__site_domain_move__source__target-instance_route
  */
 public function moveDomain($site, $domains, $sourceEnv, $targetEnv, $skipSiteUpdate = FALSE)
 {
     $paths = '{+base_path}/sites/{site}/domain-move/{source}/{target}.json';
     $update_site = '';
     if ($skipSiteUpdate) {
         $update_site = '1';
         $paths .= '?skip_site_update={update_site}';
     }
     $variables = array('site' => $site, 'source' => $sourceEnv, 'target' => $targetEnv, 'update_site' => $update_site);
     $body = Json::encode(array('domains' => (array) $domains));
     $request = $this->post(array($paths, $variables), null, $body);
     return new Response\Task($request);
 }