Skip to content

Commit

Permalink
Add deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
bytehead committed Apr 26, 2022
1 parent 511fbac commit 6d06203
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core-bundle/src/Picker/AbstractTablePickerProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ 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))
&& 0 !== \count($this->getModulesForTable($table));
Expand Down
10 changes: 10 additions & 0 deletions core-bundle/tests/Picker/TablePickerProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function testName(): void
$this->assertSame('tablePicker', $provider->getName());
}

/**
* @group legacy
*
* @expectedDeprecation Since contao/core-bundle 4.9: The usage of a non fully qualified class name as DataContainer name has been deprecated %s.
*/
public function testSupportsLegacyContext(): void
{
$GLOBALS['TL_DCA']['tl_foobar']['config']['dataContainer'] = 'Table';
Expand Down Expand Up @@ -75,6 +80,11 @@ public function testDoesNotSupportsContextWithoutPrefix(): void
$this->assertFalse($provider->supportsContext('foobar'));
}

/**
* @group legacy
*
* @expectedDeprecation Since contao/core-bundle 4.9: The usage of a non fully qualified class name as DataContainer name has been deprecated %s.
*/
public function testDoesNotSupportContextWithoutDataContainer(): void
{
$GLOBALS['TL_DCA']['tl_foobar']['config']['dataContainer'] = 'Foobar';
Expand Down

0 comments on commit 6d06203

Please sign in to comment.