/** * @param string $className * @param string $version * * @return DataFixture */ protected function createDataFixture($className, $version) { $result = new DataFixture(); $result->setClassName($className); $result->setVersion($version); return $result; }
public function testDataFixtureEntity() { $this->assertNull($this->dataFixtureEntity->getId()); $this->assertNull($this->dataFixtureEntity->getClassName()); $this->dataFixtureEntity->setClassName('testClass'); $this->assertEquals('testClass', $this->dataFixtureEntity->getClassName()); $this->assertNull($this->dataFixtureEntity->getLoadedAt()); $this->dataFixtureEntity->setLoadedAt(new \DateTime('2013-01-01')); $this->assertEquals('2013-01-01', $this->dataFixtureEntity->getLoadedAt()->format('Y-m-d')); }
/** * @inheritdoc */ public function load(ObjectManager $manager) { if (!empty($this->dataFixturesClassNames)) { $loadedAt = new \DateTime('now', new \DateTimeZone('UTC')); foreach ($this->dataFixturesClassNames as $className => $version) { $dataFixture = null; if ($version !== null) { $dataFixture = $manager->getRepository('OroMigrationBundle:DataFixture')->findOneBy(['className' => $className]); } if (!$dataFixture) { $dataFixture = new DataFixture(); $dataFixture->setClassName($className); } $dataFixture->setVersion($version)->setLoadedAt($loadedAt); $manager->persist($dataFixture); } $manager->flush(); } }