mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
refactor loading for social issues using real data
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\PersonBundle\Service\Import\SocialWorkMetadata;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use League\Csv\Reader;
|
||||
|
||||
class LoadSocialWorkMetadata extends \Doctrine\Bundle\FixturesBundle\Fixture implements \Doctrine\Common\DataFixtures\OrderedFixtureInterface
|
||||
{
|
||||
private SocialWorkMetadata $importer;
|
||||
|
||||
/**
|
||||
* @param SocialWorkMetadata $importer
|
||||
*/
|
||||
public function __construct(SocialWorkMetadata $importer)
|
||||
{
|
||||
$this->importer = $importer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
try {
|
||||
$csv = Reader::createFromPath(__DIR__.'/data/social_work_metadata.csv');
|
||||
} catch (Throwable $e) {
|
||||
throw new Exception('Error while loading CSV.',0, $e);
|
||||
}
|
||||
|
||||
$csv->setDelimiter(";");
|
||||
|
||||
$this->importer->import($csv);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return 9500;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user