/** * {@inheritdoc} */ public function transform(Document $document) { $agencyInternal = false === $this->internal ? '0' : '1'; $entity = $document->currentEntity(); $entity->addProperty($document->createProperty('agency_id', 'string', $this->public_id)); $entity->addProperty($document->createProperty('agency_name', 'string', $this->name)); $entity->addProperty($document->createProperty('agency_internal', 'boolean', $agencyInternal)); }
public function testCantSetCursorOnForeignEntity() { $doc = new Document(); $doc->appendEntity($doc->createEntity('bar')); $doc2 = new Document(); $foo = $doc2->createEntity('foo'); $doc->setCursorOnEntity($foo); $this->assertNotEquals(spl_object_hash($foo), spl_object_hash($doc->currentEntity())); }
/** * {@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); } }
/** * {@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()))); } }
/** * {@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)); } }
/** * {@inheritdoc} * * @param \Bpi\RestMediaTypeBundle\Document $document */ public function transform(\Bpi\RestMediaTypeBundle\Document $document) { $document->currentEntity()->addProperty($document->createProperty($this->name, 'yearwheel', $this->name)); }
/** * {@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)); } }