1: <?php
2:
3: namespace Mapbender\CoreBundle\DataFixtures\ORM;
4:
5: use Doctrine\Common\Persistence\ObjectManager;
6: use Doctrine\Common\DataFixtures\FixtureInterface;
7: use Mapbender\CoreBundle\Entity\SRS;
8:
9: 10: 11: 12: 13:
14: class LoadEpsgData implements FixtureInterface
15: {
16:
17: 18: 19:
20: public function load(ObjectManager $manager)
21: {
22: $filepath = __DIR__ . '/../../../Resources/proj4/proj4js_epsg.txt';
23: $file = @fopen($filepath, "r");
24: while(!feof($file))
25: {
26: $help = trim(str_ireplace("\n", "", fgets($file)));
27: if(strlen($help) === 0)
28: {
29: continue;
30: }
31: $temp = explode("|", $help);
32: if($temp[0] === null || strlen($temp[0]) === 0)
33: {
34: continue;
35: }
36: $srs = new SRS();
37: $srs->setName($temp[0]);
38: $srs->setTitle($temp[1]);
39: $srs->setDefinition($temp[2]);
40:
41: $manager->persist($srs);
42: }
43: $manager->flush();
44: fclose($file);
45: }
46:
47: }
48: