src/Contao/Dca/Populator/DataProviderPopulator.php
public function populate(EnvironmentInterface $environment)
    {
        foreach ($environment->getDataDefinition()->getDataProviderDefinition() as $information) {
            if ($information instanceof ContaoDataProviderInformation) {
                if ($environment->hasDataProvider($information->getName())) {
                    throw new DcGeneralRuntimeException(
                        \sprintf(
                            'Data provider %s already added to environment.',
                            $information->getName()
                        )
                    );
                }

                /** @var DataProviderInterface $dataProvider */
                $dataProvider = (new \ReflectionClass($information->getClassName()))->newInstance();
                if ($initializationData = $information->getInitializationData()) {
                    $dataProvider->setBaseConfig($initializationData);
                }

                $environment->addDataProvider($information->getName(), $dataProvider);
            }
        }
    }
public function populate(EnvironmentInterface $environment)
    {
        foreach ($environment->getDataDefinition()->getDataProviderDefinition() as $information) {
            if ($information instanceof ContaoDataProviderInformation) {
                if ($environment->hasDataProvider($information->getName())) {
                    throw new DcGeneralRuntimeException(
                        \sprintf(
                            'Data provider %s already added to environment.',
                            $information->getName()
                        )
                    );
                }

                /** @var DataProviderInterface $dataProvider */
                $dataProvider = (new \ReflectionClass($information->getClassName()))->newInstance();
                if ($initializationData = $information->getInitializationData()) {
                    $dataProvider->setBaseConfig($initializationData);
                }

                $environment->addDataProvider($information->getName(), $dataProvider);
            }
        }
    }
public function populate ( EnvironmentInterface $ environment ) { foreach ( $ environment -> getDataDefinition ( ) -> getDataProviderDefinition ( ) as $ information ) { if ( $ information instanceof ContaoDataProviderInformation ) { if ( $ environment -> hasDataProvider ( $ information -> getName ( ) ) ) { throw new DcGeneralRuntimeException ( \ sprintf ( 'Data provider %s already added to environment.' , $ information -> getName ( ) ) ) ; } /** @var DataProviderInterface $dataProvider */ $ dataProvider = ( new \ ReflectionClass ( $ information -> getClassName ( ) ) ) -> newInstance ( ) ; if ( $ initializationData = $ information -> getInitializationData ( ) ) { $ dataProvider -> setBaseConfig ( $ initializationData ) ; } $ environment -> addDataProvider ( $ information -> getName ( ) , $ dataProvider ) ; } } }
Instantiates and adds the data providers implementing ContaoDataProviderInformation to the environment.

@param EnvironmentInterface $environment The environment to populate.

@return void

@throws DcGeneralRuntimeException When a data provider has already been added to the environment.
Instantiates and adds the data providers implementing ContaoDataProviderInformation to the environment .