Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  *
  * @param \Bpi\RestMediaTypeBundle\Document $document
  */
 public function transform(\Bpi\RestMediaTypeBundle\Document $document)
 {
     $entity = $document->createEntity('category');
     $document->appendEntity($entity);
     $entity->addProperty($document->createProperty('group', 'string', 'category'));
     $entity->addProperty($document->createProperty('name', 'string', $this->getCategory()));
 }
Ejemplo n.º 2
0
 public function testChangeOwnerOnAddEntity()
 {
     $doc = new Document();
     $doc2 = new Document();
     $bar = $doc2->createEntity('bar');
     $doc->appendEntity($bar);
     $this->assertTrue($bar->isOwner($doc));
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function transform(Document $document)
 {
     try {
         $entity = $document->currentEntity();
     } catch (\RuntimeException $e) {
         $entity = $document->createEntity('entity', 'author');
         $document->appendEntity($entity);
     }
     $entity->addProperty($document->createProperty('author', 'string', $this->getFullName()));
     if ($this->agency instanceof \Bpi\ApiBundle\Domain\Aggregate\Agency) {
         $this->agency->transform($document);
     }
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function transform(Document $document)
 {
     try {
         $entity = $document->currentEntity();
     } catch (\RuntimeException $e) {
         $entity = $document->createEntity('entity', 'profile');
         $document->appendEntity($entity);
     }
     if ($this->yearwheel instanceof Yearwheel) {
         $entity->addProperty($document->createProperty('yearwheel', 'string', $this->yearwheel->name()));
     }
     if ($this->tags && $this->tags->count()) {
         $entity->addProperty($document->createProperty('tags', 'string', implode(', ', $this->tags->toArray())));
     }
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function transform(Document $document)
 {
     try {
         $entity = $document->currentEntity();
     } catch (\RuntimeException $e) {
         $entity = $document->createEntity('entity', 'statistics');
         $document->appendEntity($entity);
     }
     $fields = array('push', 'syndicate');
     foreach ($fields as $field) {
         $value = 0;
         if (isset($this->stats[$field])) {
             $value = $this->stats[$field];
         }
         $entity->addProperty($document->createProperty($field, 'string', $value));
     }
 }
Ejemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function transform(Document $document)
 {
     try {
         $entity = $document->currentEntity();
     } catch (\RuntimeException $e) {
         $entity = $document->createEntity('entity', 'resource');
         $document->appendEntity($entity);
     }
     // Add assets to presentation.
     $i = 1;
     foreach ($this->assets as $asset) {
         $assetUrl = $document->generateRoute("get_asset", array('filename' => $asset['file'], 'extension' => $asset['extension']), true);
         $entity->addProperty($document->createProperty('asset' . $i, 'asset', $assetUrl));
         $i++;
     }
     $copyleft = '<p>' . $this->copyleft . '</p>';
     $entity->addProperty($document->createProperty('title', 'string', $this->title));
     $entity->addProperty($document->createProperty('body', 'string', $this->body->getFlattenContent() . $copyleft));
     $entity->addProperty($document->createProperty('teaser', 'string', $this->teaser));
     $entity->addProperty($document->createProperty('creation', 'dateTime', $this->ctime));
     $entity->addProperty($document->createProperty('type', 'string', $this->type));
     foreach ($this->materials as $material) {
         $entity->addProperty($document->createProperty('material', 'string', (string) $material));
     }
 }
Ejemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function transform(Document $document)
 {
     $entity = $document->createEntity('entity');
     $entity->addProperty($document->createProperty('id', 'string', $this->getId()));
     $entity->addProperty($document->createProperty('pushed', 'dateTime', $this->ctime));
     $entity->addProperty($document->createProperty('editable', 'boolean', (int) $this->params->filter(function ($e) {
         if ($e instanceof Editable) {
             return true;
         }
     })->first()->isPositive()));
     $document->appendEntity($entity);
     $document->setCursorOnEntity($entity);
     $this->author->transform($document);
     $entity->addProperty($document->createProperty('category', 'string', $this->getCategory()->getCategory()));
     $entity->addProperty($document->createProperty('audience', 'string', $this->getAudience()->getAudience()));
     $entity->addProperty($document->createProperty('syndications', 'string', null === $this->getSyndications() ? 0 : $this->getSyndications()));
     $this->profile->transform($document);
     $this->resource->transform($document);
 }