/** * Persist import to target entity manager. * * This assumes that the import table is on the same database as the target * resource. This should be more flexible. * * @todo Allow seperate entity manager for import persistence. * @param ImportEvent $event */ public function persistImport(ImportEvent $event) { $om = $event->getTarget()->getManager(); $import = $event->getImport(); $import->setEndTimestamp(); $om->persist($import); }
public function testImportEventIsSettableUponCreation() { $import = Mockery::mock('DAG\\Component\\Resource\\Model\\Import'); $subject = Mockery::mock('DAG\\Bundle\\ResourceBundle\\Import\\ResourceInterface')->shouldReceive('isSubject')->zeroOrMoreTimes()->andReturn(true)->getMock(); $target = Mockery::mock('DAG\\Bundle\\ResourceBundle\\Import\\ResourceInterface')->shouldReceive('isTarget')->zeroOrMoreTimes()->andReturn(true)->getMock(); $event = new ImportEvent($subject, $target, $import); $this->assertSame($import, $event->getImport()); }
/** * Initialize the import object. * * Figure out criteria to use... * * @param ImportEvent $event */ public function initialize(ImportEvent $event) { $import = $event->getImport(); $history = $event->getHistory(); $importer = $event->getImporter(); $criteria = array(); if (empty($history)) { $criteria = $this->criteria->setParams($this->criteria->retrieveDefault()); } if (empty($criteria)) { $criteria = $this->criteria->setParams($this->criteria->calculate($history)); } $import->setImporter($importer->getName()); $import->setCriteria($criteria->retrieve()); }