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

Calling a fixtures load inside of a class #336

Open
geoff-maddock opened this issue Dec 14, 2020 · 1 comment
Open

Calling a fixtures load inside of a class #336

geoff-maddock opened this issue Dec 14, 2020 · 1 comment

Comments

@geoff-maddock
Copy link

If I run a fixtures load command from the command line, it works as expected:

/srv/api # php bin/console doctrine:fixtures:load

 Careful, database "powerdns" will be purged. Do you want to continue? (yes/no) [no]:
 > yes

   > purging database
   > loading App\DataFixtures\AppFixtures

But if I set up and call the load method, no data is loaded:

        $fixture = new AppFixtures();
        $fixture->load($this->entityManager);

Is there a way to manually load fixtures data like this?

@rapliandras
Copy link

There should be, but the interactive mode is incorrectly handled. I've submitted a fix waiting for review here: #338

After this gets pulled, you can call it from another command like this:

$command = $this->getApplication()->find('doctrine:fixtures:load');
$command->run(new ArrayInput(["--no-interaction" => true]), $output);

Or from your controller as in https://symfony.com/doc/current/console/command_in_controller.html

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

2 participants