/**
  * This method parses all data provider related information from Contao legacy data container arrays.
  *
  * @param ContainerInterface $container The container where the data shall be stored.
  *
  * @return void
  */
 protected function parseDataProvider(ContainerInterface $container)
 {
     if ($container->hasDataProviderDefinition()) {
         $config = $container->getDataProviderDefinition();
     } else {
         $config = new DefaultDataProviderDefinition();
         $container->setDataProviderDefinition($config);
     }
     // If mode is 5, we need to define tree view.
     if ($this->getFromDca('list/sorting/mode') === 5) {
         if (!$container->getBasicDefinition()->getRootDataProvider()) {
             $container->getBasicDefinition()->setRootDataProvider($container->getName());
         }
     }
     if (($parentTable = $this->getFromDca('config/ptable')) !== null) {
         // Check config if it already exists, if not, add it.
         if (!$config->hasInformation($parentTable)) {
             $providerInformation = new ContaoDataProviderInformation();
             $providerInformation->setName($parentTable);
             $config->addInformation($providerInformation);
         } else {
             $providerInformation = $config->getInformation($parentTable);
         }
         if ($providerInformation instanceof ContaoDataProviderInformation) {
             $initializationData = (array) $providerInformation->getInitializationData();
             $providerInformation->setTableName($parentTable)->setInitializationData(array_merge(array('source' => $parentTable, 'name' => $parentTable), $initializationData));
             if (!$container->getBasicDefinition()->getRootDataProvider()) {
                 $container->getBasicDefinition()->setRootDataProvider($parentTable);
             }
             if (!$container->getBasicDefinition()->getParentDataProvider()) {
                 $container->getBasicDefinition()->setParentDataProvider($parentTable);
             }
         }
     }
     $providerName = $container->getBasicDefinition()->getDataProvider() ?: $container->getName();
     // Check config if it already exists, if not, add it.
     if (!$config->hasInformation($providerName)) {
         $providerInformation = new ContaoDataProviderInformation();
         $providerInformation->setName($providerName);
         $config->addInformation($providerInformation);
     } else {
         $providerInformation = $config->getInformation($providerName);
     }
     if ($providerInformation instanceof ContaoDataProviderInformation) {
         $initializationData = (array) $providerInformation->getInitializationData();
         if (!isset($initializationData['source'])) {
             $providerInformation->setTableName($providerName)->setInitializationData(array_merge(array('source' => $providerName, 'name' => $providerName), $initializationData));
         }
         $providerInformation->setVersioningEnabled((bool) $this->getFromDca('config/enableVersioning'));
         if (!$container->getBasicDefinition()->getDataProvider()) {
             $container->getBasicDefinition()->setDataProvider($providerName);
         }
     }
 }
 /**
  * This method parses all data provider related information from Contao legacy data container arrays.
  *
  * @param ContainerInterface $container The container where the data shall be stored.
  *
  * @return void
  */
 protected function parseDataProvider(ContainerInterface $container)
 {
     // Parse data provider.
     if ($container->hasDataProviderDefinition()) {
         $config = $container->getDataProviderDefinition();
     } else {
         $config = new DefaultDataProviderDefinition();
         $container->setDataProviderDefinition($config);
     }
     // First check if we are using the "new" notation used in DcGeneral 0.9.
     if (!is_array($this->getFromDca('dca_config/data_provider'))) {
         return;
     }
     $dataProvidersDca = $this->getFromDca('dca_config/data_provider');
     foreach ($dataProvidersDca as $dataProviderDcaName => $dataProviderDca) {
         $providerInformation = $this->parseSingleDataProvider($container, $config, $dataProviderDca, $dataProviderDcaName);
         if ($providerInformation instanceof ContaoDataProviderInformation) {
             $baseInitializationData = array('name' => $dataProviderDcaName);
             $initializationData = (array) $providerInformation->getInitializationData();
             switch ((string) $dataProviderDcaName) {
                 case 'default':
                     $providerInformation->setVersioningEnabled((bool) $this->getFromDca('config/enableVersioning'));
                     $container->getBasicDefinition()->setDataProvider($providerInformation->getName());
                     $baseInitializationData['name'] = $providerInformation->getName();
                     break;
                 case 'root':
                     $container->getBasicDefinition()->setRootDataProvider($providerInformation->getName());
                     $baseInitializationData['name'] = $providerInformation->getName();
                     break;
                 case 'parent':
                     $container->getBasicDefinition()->setParentDataProvider($providerInformation->getName());
                     $baseInitializationData['name'] = $providerInformation->getName();
                     break;
                 default:
             }
             $providerInformation->setInitializationData(array_merge($baseInitializationData, $dataProviderDca, $initializationData));
         }
     }
 }