-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
345 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2019 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -13,7 +13,8 @@ | |
* @package contao-community-alliance/dc-general | ||
* @author Christian Schiffler <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @copyright 2013-2019 Contao Community Alliance. | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -121,7 +122,7 @@ private function addParentFilter(ModelIdInterface $idParent, ConfigInterface $co | |
$baseFilter = $config->getFilter(); | ||
$filter = $condition->getFilter($parent); | ||
|
||
if ($baseFilter) { | ||
if (\is_array($baseFilter)) { | ||
$filter = array_merge($baseFilter, $filter); | ||
} | ||
|
||
|
@@ -144,6 +145,7 @@ private function addParentFilter(ModelIdInterface $idParent, ConfigInterface $co | |
private function buildBaseConfig(?ModelIdInterface $parentId): ConfigInterface | ||
{ | ||
$environment = $this->getEnvironment(); | ||
assert($environment instanceof EnvironmentInterface); | ||
$provider = $environment->getDataProvider(); | ||
if (null === $provider) { | ||
throw new DcGeneralRuntimeException('Data provider not set.'); | ||
|
@@ -156,7 +158,7 @@ private function buildBaseConfig(?ModelIdInterface $parentId): ConfigInterface | |
$additional = $definition->getBasicDefinition()->getAdditionalFilter(); | ||
|
||
// Custom filter common for all modes. | ||
if ($additional) { | ||
if (\is_array($additional)) { | ||
$config->setFilter($additional); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2022 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -15,7 +15,7 @@ | |
* @author Tristan Lins <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2022 Contao Community Alliance. | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -60,7 +60,7 @@ public function __construct($callback, $restrictions = null) | |
{ | ||
$this->callback = $callback; | ||
|
||
if ($restrictions) { | ||
if (\is_array($restrictions)) { | ||
call_user_func_array([$this, 'setRestrictions'], $restrictions); | ||
} | ||
} | ||
|
@@ -86,7 +86,7 @@ public function setRestrictions(?string $dataContainerName = null) | |
*/ | ||
public function wantToExecute($event) | ||
{ | ||
if (empty($this->dataContainerName)) { | ||
if (null === $this->dataContainerName) { | ||
return true; | ||
} | ||
if (!$event instanceof EnvironmentAwareInterface) { | ||
|
@@ -95,6 +95,7 @@ public function wantToExecute($event) | |
if (null === $definition = $event->getEnvironment()->getDataDefinition()) { | ||
return false; | ||
} | ||
|
||
return ($this->dataContainerName === $definition->getName()); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2020 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -13,7 +13,8 @@ | |
* @package contao-community-alliance/dc-general | ||
* @author Christian Schiffler <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @copyright 2013-2020 Contao Community Alliance. | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -66,7 +67,7 @@ public function setRestrictions(?string $dataContainerName = null, ?string $prop | |
public function wantToExecute($event) | ||
{ | ||
return parent::wantToExecute($event) | ||
&& (empty($this->propertyName) || ($this->propertyName === $this->getProperty($event))); | ||
&& (null === $this->propertyName || ($this->propertyName === $this->getProperty($event))); | ||
} | ||
|
||
private function getProperty(Event $event): string | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2019 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -14,7 +14,8 @@ | |
* @author Christian Schiffler <[email protected]> | ||
* @author Tristan Lins <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @copyright 2013-2019 Contao Community Alliance. | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -59,9 +60,7 @@ public function setRestrictions($dataContainerName = null, $operationName = null | |
public function wantToExecute($event) | ||
{ | ||
return parent::wantToExecute($event) | ||
&& (empty($this->operationName) | ||
|| ($this->operationName === $event->getKey()) | ||
); | ||
&& (null === $this->operationName || ($this->operationName === $event->getKey())); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2019 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -14,7 +14,8 @@ | |
* @author Christian Schiffler <[email protected]> | ||
* @author Tristan Lins <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @copyright 2013-2019 Contao Community Alliance. | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -38,7 +39,7 @@ class ContainerOnLoadCallbackListener extends AbstractCallbackListener | |
*/ | ||
public function wantToExecute($event) | ||
{ | ||
if (empty($this->dataContainerName)) { | ||
if (null === $this->dataContainerName) { | ||
return true; | ||
} | ||
if (null === $definition = $event->getDcGeneral()->getEnvironment()->getDataDefinition()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2020 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -15,7 +15,8 @@ | |
* @author Tristan Lins <[email protected]> | ||
* @author David Molineus <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @copyright 2013-2020 Contao Community Alliance. | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -69,9 +70,7 @@ public function wantToExecute($event) | |
} | ||
|
||
return parent::wantToExecute($event) | ||
&& (empty($this->operationName) | ||
|| ($this->operationName === $event->getKey()) | ||
); | ||
&& (null === $this->operationName || ($this->operationName === $event->getKey())); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2022 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -16,7 +16,7 @@ | |
* @author Tristan Lins <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2022 Contao Community Alliance. | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -118,7 +118,7 @@ function (PopulateEnvironmentEvent $event) use ($dataContainerName) { | |
} | ||
|
||
$parentName = $definition->getBasicDefinition()->getParentDataProvider(); | ||
if ($parentName) { | ||
if (null !== $parentName) { | ||
$parentDefinition = ($parentName === $definition->getName()) | ||
? $definition | ||
: (new DcGeneralFactory()) | ||
|
@@ -133,7 +133,7 @@ function (PopulateEnvironmentEvent $event) use ($dataContainerName) { | |
} | ||
|
||
$rootName = $definition->getBasicDefinition()->getRootDataProvider(); | ||
if ($rootName) { | ||
if (null !== $rootName) { | ||
$rootDefinition = ($rootName === $definition->getName()) | ||
? $definition | ||
: (new DcGeneralFactory()) | ||
|
@@ -221,13 +221,13 @@ protected function parseSingleDataProvider( | |
ContainerInterface $container, | ||
DataProviderDefinitionInterface $providers, | ||
array $information, | ||
$name | ||
?string $name | ||
) { | ||
if (isset($information['factory'])) { | ||
$providerInformation = (new \ReflectionClass($information['factory']))->newInstance()->build($information); | ||
} else { | ||
// Determine the name. | ||
if ($name && !$this->isSpecialName($name)) { | ||
if (null !== $name && !$this->isSpecialName($name)) { | ||
$providerName = $name; | ||
} elseif ('default' === $name) { | ||
$providerName = $container->getName(); | ||
|
@@ -249,13 +249,11 @@ protected function parseSingleDataProvider( | |
if (!$providerInformation instanceof ContaoDataProviderInformation) { | ||
return $providerInformation; | ||
} | ||
if (!$providerInformation->getTableName()) { | ||
if (null === $providerInformation->getTableName()) { | ||
if (isset($information['source'])) { | ||
$providerInformation | ||
->setTableName($information['source']); | ||
$providerInformation->setTableName($information['source']); | ||
} else { | ||
$providerInformation | ||
->setTableName($providerName); | ||
$providerInformation->setTableName($providerName); | ||
} | ||
} | ||
|
||
|
@@ -384,7 +382,7 @@ protected function parseRootCondition( | |
if (null !== ($rootCondition = $this->getFromDca('dca_config/rootEntries'))) { | ||
$rootProvider = $container->getBasicDefinition()->getRootDataProvider(); | ||
|
||
if (!$rootProvider) { | ||
if (null === $rootProvider) { | ||
throw new DcGeneralRuntimeException( | ||
'Root data provider name not specified in DCA but rootEntries section specified.' | ||
); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
/** | ||
* This file is part of contao-community-alliance/dc-general. | ||
* | ||
* (c) 2013-2023 Contao Community Alliance. | ||
* (c) 2013-2024 Contao Community Alliance. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
|
@@ -17,7 +17,7 @@ | |
* @author Stefan Heimes <[email protected]> | ||
* @author Sven Baumann <[email protected]> | ||
* @author Ingolf Steinhardt <[email protected]> | ||
* @copyright 2013-2023 Contao Community Alliance. | ||
* @copyright 2013-2024 Contao Community Alliance. | ||
* @license https://github.com/contao-community-alliance/dc-general/blob/master/LICENSE LGPL-3.0-or-later | ||
* @filesource | ||
*/ | ||
|
@@ -514,7 +514,7 @@ protected function parseDataProvider(ContainerInterface $container) | |
// If mode is 5, we need to define tree view. | ||
if ( | ||
(5 === $this->getFromDca('list/sorting/mode')) | ||
&& !$container->getBasicDefinition()->getRootDataProvider() | ||
&& null === $container->getBasicDefinition()->getRootDataProvider() | ||
) { | ||
$container->getBasicDefinition()->setRootDataProvider($container->getName()); | ||
} | ||
|
@@ -544,16 +544,16 @@ protected function parseDataProvider(ContainerInterface $container) | |
) | ||
); | ||
|
||
if (!$container->getBasicDefinition()->getRootDataProvider()) { | ||
if (null === $container->getBasicDefinition()->getRootDataProvider()) { | ||
$container->getBasicDefinition()->setRootDataProvider($parentTable); | ||
} | ||
if (!$container->getBasicDefinition()->getParentDataProvider()) { | ||
if (null === $container->getBasicDefinition()->getParentDataProvider()) { | ||
$container->getBasicDefinition()->setParentDataProvider($parentTable); | ||
} | ||
} | ||
} | ||
|
||
$providerName = $container->getBasicDefinition()->getDataProvider() ?: $container->getName(); | ||
$providerName = $container->getBasicDefinition()->getDataProvider() ?? $container->getName(); | ||
|
||
// Check config if it already exists, if not, add it. | ||
if (!$config->hasInformation($providerName)) { | ||
|
@@ -590,7 +590,7 @@ protected function parseDataProvider(ContainerInterface $container) | |
// @codingStandardsIgnoreEnd | ||
} | ||
|
||
if (!$container->getBasicDefinition()->getDataProvider()) { | ||
if (null === $container->getBasicDefinition()->getDataProvider()) { | ||
$container->getBasicDefinition()->setDataProvider($providerName); | ||
} | ||
} | ||
|
@@ -625,7 +625,7 @@ protected function getRootProviderName(ContainerInterface $container) | |
{ | ||
$rootProvider = $container->getBasicDefinition()->getRootDataProvider(); | ||
|
||
if (!$rootProvider) { | ||
if (null === $rootProvider) { | ||
throw new DcGeneralRuntimeException( | ||
'Root data provider name not specified in DCA but rootEntries section specified.' | ||
); | ||
|
@@ -872,6 +872,7 @@ protected function parseListSorting(ListingConfigInterface $listing, array $list | |
$parsedProperties = []; | ||
$sortingDca = ($listDca['sorting'] ?? []); | ||
|
||
/** @psalm-suppress RiskyTruthyFalsyComparison */ | ||
if ($headerFields = ($sortingDca['headerFields'] ?? [])) { | ||
assert(\is_array($headerFields)); | ||
/** @var list<string> $headerFields */ | ||
|
Oops, something went wrong.