Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not loading fixtures #379

Open
malutanpetronel opened this issue Jan 27, 2022 · 1 comment
Open

Not loading fixtures #379

malutanpetronel opened this issue Jan 27, 2022 · 1 comment

Comments

@malutanpetronel
Copy link

Hi

I use doctrine/doctrine-fixtures-bundle": "^3.3", now is 3.4.0
and I try to load my fixtures from a data.yml file with:

bin/console doctrine:fixtures:load --em=blog --env=webnou --group=webnou

from a LoadUserData class

class LoadUserData extends Fixture implements ContainerAwareInterface, FixtureGroupInterface
{
/**
* @var ContainerInterface
*/
private $container;

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

public function load(ObjectManager $manager)
{
    $fixturesFiles = [
        __DIR__.'/data.yml',
    ];

    $loader = new Doctrine\Common\DataFixtures\Loader();

    return $loader->loadFromFile($fixturesFiles[0]);
}

public static function getGroups(): array
{
    return ['webnou'];
}

}

I have the data.yml specified above with the content:

include:
- data/categorii.yml

and

categorii.yml specified above

App\Blogger\BlogBundle\Entity\Cat:

root:
name: ROOT

servicii_web:
name: Web
parent: '@root'
....

and 

namespace App\Blogger\BlogBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**

  • Blogger\BlogBundle\Entity\Cat

  • @gedmo\Tree(type="nested")

  • use repository for handy tree functions

  • @Orm\Entity(repositoryClass="App\Blogger\BlogBundle\Entity\Repository\CatRepository")

  • @Orm\Table(name="cat")

  • @Orm\HasLifecycleCallbacks
    /
    class Cat
    {
    /
    *

    • @Orm\Id
    • @Orm\Column(type="integer")
    • @Orm\GeneratedValue(strategy="AUTO")
      */
      protected $id;

    /**

    • @Orm\Column(name="name", type="string", length=64)
      */
      protected $name;

    /**

    • This will keep the slug for the blog. The size of field was estimated to
    • 45/3letters word + - which will replace the spaces
    • @var string
    • @gedmo\Slug(fields={"name"})
    • @Orm\Column(name="slug", type="string", length=60, unique=true)
      */
      protected $slug;

    /**

    • @gedmo\TreeLeft
    • @Orm\Column(type="integer", nullable=true)
      */
      protected $lft;
      ....

but bin/console doctrine:fixtures:load --em=blog --env=webnou --group=webnou after answering yes for purge is not creating any row in the cat table :( I am lost for the moment and maybe you can provide a hint or an ideea...

@malutanpetronel
Copy link
Author

I see now that
private function loadFromIterator(Iterator $iterator): array
is require_once $sourceFile;
so is expecting a PHP file as long as I send a yml file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant