Ejemplo n.º 1
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));
     }
 }