Ejemplo n.º 1
0
 public function testConstruct()
 {
     $objectExporter = new ObjectExporter();
     $t = function ($type) {
         return Type::create($type);
     };
     $set = new Set();
     // set implements Walkable
     $set->set('name', 'oids_pages', $t('String'));
     $j1 = new Set();
     $j1->set('name', 'oid', $t('String'));
     $j1->set('referencedColumnName', 'oid', $t('String'));
     $j1->set('onDelete', 'cascade', $t('String'));
     $j2 = new Set();
     $j2->set('name', 'page_id', $t('String'));
     $j2->set('referencedColumnName', 'id', $t('String'));
     $j2->set('onDelete', 'cascade', $t('String'));
     $set->set('joinColumns', array($j1, $j2), new ArrayType(new ObjectType(new GClass('Psc\\Data\\Walkable'))));
     $set->set('inverseJoinColumns', array($j2, $j1), new ArrayType(new ObjectType(new GClass('Psc\\Data\\Walkable'))));
     $this->assertInstanceOf('stdClass', $object = $objectExporter->walkWalkable($set));
     $this->assertInternalType('array', $object->joinColumns);
     $this->assertInternalType('array', $object->inverseJoinColumns);
     $this->assertInstanceOf('stdClass', $object->joinColumns[0]);
     $this->assertInstanceOf('stdClass', $object->inverseJoinColumns[0]);
 }
Ejemplo n.º 2
0
 public function export()
 {
     $meta = new SetMeta();
     foreach ($this->getSetMeta()->getTypes() as $property => $type) {
         // @TODO schön wäre eigentlich auf ebene 2 immer nur "entity:id" zu exportieren
         // das müsste dann alle relevanten daten für die response haben
         if ($type instanceof EntityType || $type instanceof PersistentCollectionType) {
             continue;
         }
         $meta->setFieldType($property, $type);
     }
     $set = new Set(array(), $meta);
     foreach ($set->getKeys() as $property) {
         $set->set($property, $this->callGetter($property));
     }
     $exporter = new ObjectExporter();
     return $exporter->walkWalkable($set);
 }