Php Symfony 4-在夹具中加载YML文件

Php Symfony 4-在夹具中加载YML文件,php,doctrine,symfony4,fixture,Php,Doctrine,Symfony4,Fixture,我想要一些关于Symfony 4.1的特定主题的帮助。 我想加载一些存储在YML文件中的数据以使用fixture。 为了加载这个文件,我使用了依赖项注入,但我不明白为什么没有达到加载函数 下面是我的代码: 上诉: <?php namespace App\DependencyInjection; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjectio

我想要一些关于Symfony 4.1的特定主题的帮助。 我想加载一些存储在YML文件中的数据以使用fixture。 为了加载这个文件,我使用了依赖项注入,但我不明白为什么没有达到加载函数

下面是我的代码:

上诉:

    <?php
    namespace App\DependencyInjection;

    use Symfony\Component\Config\FileLocator;
    use Symfony\Component\DependencyInjection\ContainerBuilder;
    use Symfony\Component\DependencyInjection\Loader;
    use Symfony\Component\DependencyInjection\Extension\Extension;

    /**
     */
    class AppExtension extends Extension
    {
        /**
         * @see Symfony\Component\DependencyInjection\Extension.ExtensionInterface::load()
         */
        public function load(array $configs, ContainerBuilder $container)
        {
            $configuration = new Configuration();
            $config = $this->processConfiguration($configuration, $configs);

            $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
            $loader->load('services.yml');
            //$loader->load('parameters.yml');

            echo __DIR__.'/../Resources/DataFixtures';
            die();

            $fixture_loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/DataFixtures'));
            $fixture_loader->load('Patients.yml');

            $data_loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/datas'));
            //$data_loader->load('first_name.yml')
        }
    }

<?php

namespace App\DependencyInjection;

use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;

/**
 * This is the class that validates and merges configuration from your app/config files.
 *
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/configuration.html}
 */
class Configuration implements ConfigurationInterface
{
    /**
     * {@inheritdoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('app');

        // Here you should define the parameters that are allowed to
        // configure your bundle. See the documentation linked above for
        // more information on that topic.

        return $treeBuilder;
    }
}
<?php
namespace App\DataFixtures\ORM;

use Doctrine\Common\Persistence\ObjectManager;
use App\Entity\Patient;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Symfony\Component\DependencyInjection\ContainerInterface;


class LoadPatientData extends Fixture {
    /**
     *
     * @var ContainerInterface
     */
    private $container;


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

    public function load(ObjectManager $manager)
    {
        //var_dump($this->container)

        $patientsArray = $this->container->getParameter('Patient');

        foreach( $patientsArray as $name => $object )
        {
            $patient = new Patient();

            foreach( $object as $key => $value )
            {
                $patient->{$key}($value);
            }

            $manager->persist($patient);
            $this->addReference($name, $patient);
        }
        $manager->flush();
    }

}