예제 #1
0
 /**
  * Insert one new record using the Entity class.
  */
 public function execute(Mandango $mandango, $insertedEntities)
 {
     $metadata = $mandango->getMetadata($this->class);
     $obj = $mandango->create($this->class);
     foreach ($this->columnFormatters as $column => $format) {
         if (null !== $format) {
             $value = is_callable($format) ? $format($insertedEntities, $obj) : $format;
             if (isset($metadata['fields'][$column]) || isset($metadata['referencesOne'][$column])) {
                 $obj->set($column, $value);
             }
             if (isset($metadata['referencesMany'][$column])) {
                 $adder = 'add' . ucfirst($column);
                 $obj->{$adder}($value);
             }
         }
     }
     $mandango->persist($obj);
     return $obj;
 }
예제 #2
0
 /**
  * @dataProvider getMetadataProvider
  */
 public function testGetMetadata($documentClass)
 {
     $metadataFactory = $this->getMock('Mandango\\MetadataFactory');
     $metadataFactory->expects($this->once())->method('getClass')->with($this->equalTo($documentClass));
     $mandango = new Mandango($metadataFactory, $this->cache);
     $mandango->getMetadata($documentClass);
 }
예제 #3
0
 /**
  * Constructor
  *
  * @param Mandango $objectManager The ObjectManager to use
  * @param string   $modelClass    The FQCN of the hydrated/extracted object
  */
 public function __construct(Mandango $mandango, $modelClass)
 {
     parent::__construct();
     $this->mandango = $mandango;
     $this->metadata = $mandango->getMetadata($modelClass);
 }