protected function parseDataProvider(IMetaModelDataDefinition $container)
{
$config = $this->getDataProviderDefinition($container);
// Check config if it already exists, if not, add it.
if (!$config->hasInformation($container->getName())) {
$providerInformation = new ContaoDataProviderInformation();
$providerInformation->setName($container->getName());
$config->addInformation($providerInformation);
} else {
$providerInformation = $config->getInformation($container->getName());
}
if ($providerInformation instanceof ContaoDataProviderInformation) {
$providerInformation->setTableName($container->getName())->setClassName('MetaModels\\DcGeneral\\Data\\Driver')->setInitializationData(array('source' => $container->getName(), 'service-container' => $this->serviceContainer))->setVersioningEnabled(false);
$container->getBasicDefinition()->setDataProvider($container->getName());
}
// If in hierarchical mode, set the root provider.
if ($container->getBasicDefinition()->getMode() == BasicDefinitionInterface::MODE_HIERARCHICAL) {
$container->getBasicDefinition()->setRootDataProvider($container->getName());
}
$inputScreen = $this->getInputScreenDetails();
// If not standalone, set the correct parent provider.
if (!$inputScreen->isStandalone()) {
// Check config if it already exists, if not, add it.
if (!$config->hasInformation($inputScreen->getParentTable())) {
$providerInformation = new ContaoDataProviderInformation();
$providerInformation->setName($inputScreen->getParentTable());
$config->addInformation($providerInformation);
} else {
$providerInformation = $config->getInformation($inputScreen->getParentTable());
}
if ($providerInformation instanceof ContaoDataProviderInformation) {
$providerInformation->setTableName($inputScreen->getParentTable())->setInitializationData(array('source' => $inputScreen->getParentTable(), 'service-container' => $this->serviceContainer));
// How can we honor other drivers? We do only check for MetaModels and legacy SQL here.
if (in_array($inputScreen->getParentTable(), $this->serviceContainer->getFactory()->collectNames())) {
$providerInformation->setClassName('MetaModels\\DcGeneral\\Data\\Driver');
}
$container->getBasicDefinition()->setParentDataProvider($inputScreen->getParentTable());
}
}
}