예제 #1
0
 /**
  * Continues the synchronization either at the next page or with the results since the initial synchronization.
  *
  * @param  string $token
  *
  * @return Result
  *
  * @api
  */
 public function continueSync($token)
 {
     if ($token instanceof Result) {
         $token = $token->getToken();
     }
     $response = $this->client->syncRequest(['sync_token' => $token]);
     return $this->buildResult($response);
 }
 public function testReviveJsonEntry()
 {
     $space = '{"sys": {"type": "Space","id": "cfexampleapi"},"name": "Contentful Example API","locales": [{"code": "en-US","default": true,"name": "English"},{"code": "tlh","default": false,"name": "Klingon"}]}';
     $ct = '{"fields": [{"id": "name","name": "Name","type": "Text","required": true,"localized": true},{"id": "likes","name": "Likes","type": "Array","required": false,"localized": false,"items": {"type": "Symbol"}},{"id": "color","name": "Color","type": "Symbol","required": false,"localized": false},{"id": "bestFriend","name": "Best Friend","type": "Link","required": false,"localized": false,"linkType": "Entry"},{"id": "birthday","name": "Birthday","type": "Date","required": false,"localized": false},{"id": "lifes","name": "Lifes left","type": "Integer","required": false,"localized": false,"disabled": true},{"id": "lives","name": "Lives left","type": "Integer","required": false,"localized": false},{"id": "image","name": "Image","required": false,"localized": false,"type": "Link","linkType": "Asset"}],"name": "Cat","displayField": "name","description": "Meow.","sys": {"space": {"sys": {"type": "Link","linkType": "Space","id": "cfexampleapi"}},"type": "ContentType","id": "cat","revision": 2,"createdAt": "2013-06-27T22:46:12.852Z","updatedAt": "2013-09-02T13:14:47.863Z"}}';
     $json = '{"fields": {"name": {"en-US": "Nyan Cat","tlh": "Nyan vIghro\'"},"likes": {"en-US": ["rainbows","fish"]},"color": {"en-US": "rainbow"},"bestFriend": {"en-US": {"sys": {"type": "Link","linkType": "Entry","id": "happycat"}}},"birthday": {"en-US": "2011-04-04T22:00:00.000Z"},"lives": {"en-US": 1337},"image": {"en-US": {"sys": {"type": "Link","linkType": "Asset","id": "nyancat"}}}},"sys": {"space": {"sys": {"type": "Link","linkType": "Space","id": "cfexampleapi"}},"type": "Entry","contentType": {"sys": {"type": "Link","linkType": "ContentType","id": "cat"}},"id": "nyancat","revision": 5,"createdAt": "2013-06-27T22:46:19.513Z","updatedAt": "2013-09-04T09:19:39.027Z"}}';
     $this->client->reviveJson($space);
     $this->client->reviveJson($ct);
     $obj = $this->client->reviveJson($json);
     $this->assertJsonStringEqualsJsonString($json, json_encode($obj));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $spaceId = $input->getArgument('space-id');
     $token = $input->getArgument('token');
     $destPath = $input->getArgument('dest-path');
     if (!file_exists($destPath)) {
         throw new \InvalidArgumentException(sprintf("Destination directory '<info>%s</info>' does not exist.", $destPath));
     }
     if (!is_writable($destPath)) {
         throw new \InvalidArgumentException(sprintf("Destination directory '<info>%s</info>' does not have write permissions.", $destPath));
     }
     $generator = $this->getClassGenerator();
     $client = new Client($token, $spaceId);
     $contentTypes = $client->getContentTypes(new Query());
     foreach ($contentTypes as $contentType) {
         $code = $generator->generateEntryClass($contentType);
         file_put_contents($destPath . '/' . $generator->getClassName($contentType) . '.php', $code);
     }
 }
예제 #4
0
 /**
  * @expectedException \RuntimeException
  */
 public function testGetSynchronizationPreview()
 {
     $client = new Client('b4c0n73n7fu1', 'cfexampleapi', true);
     $client->getSynchronizationManager();
 }
 /**
  * @param  object $sys
  *
  * @return SystemProperties
  */
 private function buildSystemProperties($sys)
 {
     return new SystemProperties(isset($sys->id) ? $sys->id : null, isset($sys->type) ? $sys->type : null, isset($sys->space) ? $this->getSpace($sys->space->sys->id) : null, isset($sys->contentType) ? $this->client->getContentType($sys->contentType->sys->id) : null, isset($sys->revision) ? $sys->revision : null, isset($sys->createdAt) ? new \DateTimeImmutable($sys->createdAt) : null, isset($sys->updatedAt) ? new \DateTimeImmutable($sys->updatedAt) : null, isset($sys->deletedAt) ? new \DateTimeImmutable($sys->deletedAt) : null);
 }