Skip to content

Commit

Permalink
Compare actual class name (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
aschempp authored and bytehead committed Apr 26, 2022
1 parent 5745d3e commit 62b20b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
7 changes: 1 addition & 6 deletions core-bundle/src/Picker/AbstractTablePickerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,7 @@ public function supportsContext($context): bool
$this->framework->initialize();
$this->framework->createInstance(DcaLoader::class, [$table])->load();

if (!class_exists($GLOBALS['TL_DCA'][$table]['config']['dataContainer']) || !class_exists($this->getDataContainer())) {
trigger_deprecation('contao/core-bundle', '4.9', 'The usage of a non fully qualified class name as DataContainer name has been deprecated and will no longer work in Contao 5.0. Use the fully qualified class name instead, e.g. Contao\DC_Table::class.');
}

return ($this->getDataContainer() === $GLOBALS['TL_DCA'][$table]['config']['dataContainer']
|| is_a(DataContainer::getDriverForTable($table), $this->getDataContainer(), true))
return $this->getDataContainer() === DataContainer::getDriverForTable($table)
&& 0 !== \count($this->getModulesForTable($table));
}

Expand Down
9 changes: 9 additions & 0 deletions core-bundle/src/Resources/contao/classes/DataContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1434,7 +1434,16 @@ public static function getDriverForTable(string $table): string

if (false === strpos($dataContainer, '\\'))
{
@trigger_error('The usage of a non fully qualified class name as DataContainer name has been deprecated and will no longer work in Contao 5.0. Use the fully qualified class name instead, e.g. Contao\DC_Table::class.', E_USER_DEPRECATED);

$dataContainer = 'DC_' . $dataContainer;

if (class_exists($dataContainer))
{
$ref = new \ReflectionClass($dataContainer);

return $ref->getName();
}
}

return $dataContainer;
Expand Down

0 comments on commit 62b20b6

Please sign in to comment.