przewiń do treści

Symfony 2 od podstaw

Włodzimierz Gajda

<?php

namespace My\FrontendBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use My\FrontendBundle\Entity\Word;

class LoadData implements FixtureInterface
{

    function load(ObjectManager $manager)
    {
        $plk = file('data/dane-testowe.txt');
        foreach ($plk as $l) {
            $Wyraz = new Word();
            $Wyraz->setTitle($l);
            $manager->persist($Wyraz);
            $manager->flush();
        }
    }
}

Listing 22.2. Plik LoadData.php z przykładu 22.1

Rozdział 22. Zachowanie sluggable

listing-22-02.txt

Reklama

Szkolenia z Symfony 2.1
©2012 Włodzimierz Gajda
ver. 1.0.1