Doctrine data fixtures içinden mevcut servisler ve parametrelere ulaşmak isterseniz, service containeri kullanılabilir hale getirmemiz gerekir. Aşağıda bunu nasıl yapacağımızı göreceğiz. Daha fazla bilgi için buraya tıklayın.


Örnek data fixtures


namespace Football\FrontendBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class CountryFixtures extends AbstractFixture implements FixtureInterface, ContainerAwareInterface
{
private $container;

public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}

public function load(ObjectManager $manager)
{
$this->container->get('name_of_the_service');
$this->container->getParameter('name_of_the_parameter');
}

.....
}