Skip to content

Commit

Permalink
Merge branch 'hotfix/fix_phpcq' into 'release/2.3.0'
Browse files Browse the repository at this point in the history
Fix PHPCQ

See merge request metamodels/core!319
  • Loading branch information
zonky2 committed Aug 19, 2024
2 parents 9187edd + d0e539e commit df1cf5c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ public function process(ContainerBuilder $container): void
// We need to keep us "first" to allow others to override the values from our loader.
if ($container->hasDefinition('translator.default')) {
$translator = $container->getDefinition('translator.default');
$loaders = $translator->getArgument(3);
$keys = array_keys($loaders);
$last = array_pop($keys);
/** @var array<string, list<string>> $loaders */
$loaders = $translator->getArgument(3);
$keys = array_keys($loaders);
$last = array_pop($keys);
if ($last === MetaModelTranslationLoader::class) {
$value = array_pop($loaders);
$loaders = [MetaModelTranslationLoader::class => $value] + $loaders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2022 The MetaModels team.
* (c) 2012-2024 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,7 @@
* @author Christian Schiffler <[email protected]>
* @author Sven Baumann <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2012-2022 The MetaModels team.
* @copyright 2012-2024 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand All @@ -35,21 +35,21 @@ class BreadcrumbStoreFactory
*
* @var IconBuilder
*/
private $iconBuilder;
private IconBuilder $iconBuilder;

/**
* The translator.
*
* @var TranslatorInterface
*/
private $translator;
private TranslatorInterface $translator;

/**
* The request stack.
*
* @var RequestStack
*/
private $requestStack;
private RequestStack $requestStack;

/**
* Create a new instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This file is part of MetaModels/core.
*
* (c) 2012-2022 The MetaModels team.
* (c) 2012-2024 The MetaModels team.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand All @@ -14,7 +14,7 @@
* @author Christian Schiffler <[email protected]>
* @author Sven Baumann <[email protected]>
* @author Ingolf Steinhardt <[email protected]>
* @copyright 2012-2022 The MetaModels team.
* @copyright 2012-2024 The MetaModels team.
* @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
* @filesource
*/
Expand All @@ -33,7 +33,7 @@ trait ConnectionTrait
*
* @var Connection
*/
private $connection;
private Connection $connection;

/**
* Set the database connection.
Expand All @@ -51,7 +51,6 @@ public function setConnection(Connection $connection)
* Retrieve the row.
*
* @param string $rowId The id.
*
* @param string $table The table to fetch from.
*
* @return object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,10 @@ private function getOptionsViaDcGeneral($metaModel, $environment, $attribute, $m
assert($dataProvider instanceof DataProviderInterface);
if ($dataProvider instanceof MultiLanguageDataProviderInterface) {
// FIXME: check if language supported.
$locale = System::getContainer()->get('request_stack')->getCurrentRequest()?->getLocale();
$languages = $dataProvider->getLanguages($model->getId());
$locale = System::getContainer()->get('request_stack')?->getCurrentRequest()?->getLocale();
if (null === ($languages = $dataProvider->getLanguages($model->getId()))) {
return [];
}
$found = false;
foreach ($languages as $language) {
if ($language->getLocale() === $locale) {
Expand All @@ -251,11 +253,11 @@ private function getOptionsViaDcGeneral($metaModel, $environment, $attribute, $m
break;
}
}
if (!$found) {
$dataProvider->setCurrentLanguage($dataProvider->getFallbackLanguage($model->getId()));
if (!$found && null !== ($language = $dataProvider->getFallbackLanguage($model->getId()))) {
$dataProvider->setCurrentLanguage($language->getLocale());
}
}
$optEv = new GetPropertyOptionsEvent($subEnv, $dataProvider->getEmptyModel());
$optEv = new GetPropertyOptionsEvent($subEnv, $dataProvider->getEmptyModel());
$optEv->setPropertyName($attribute->getColName());
$dispatcher = $subEnv->getEventDispatcher();
assert($dispatcher instanceof EventDispatcherInterface);
Expand All @@ -272,9 +274,9 @@ private function getOptionsViaDcGeneral($metaModel, $environment, $attribute, $m
* @param IAttribute $attribute The attribute.
* @param string $language The language to used for the convertion.
*
* @return string|null The value to be saved.
* @return string The value to be saved.
*/
private function aliasToId(string $alias, IAttribute $attribute, string $language): ?string
private function aliasToId(string $alias, IAttribute $attribute, string $language): string
{
if ($attribute instanceof IAliasConverter) {
$idForAlias = $attribute->getIdForAlias(substr($alias, 6), $language);
Expand Down

0 comments on commit df1cf5c

Please sign in to comment.