Skip to content

Commit

Permalink
Merge branch hotfix/v2.3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Jun 17, 2024
1 parent 0297921 commit 72dadc0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
parameters:
roadiz_core.cms_version: '2.3.10'
roadiz_core.cms_version: '2.3.11'
roadiz_core.cms_version_prefix: 'main'
env(APP_NAMESPACE): "roadiz"
env(APP_VERSION): "0.1.0"
Expand Down
16 changes: 9 additions & 7 deletions src/Form/AttributeChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace RZ\Roadiz\CoreBundle\Form;

use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ManagerRegistry;
use RZ\Roadiz\CoreBundle\Entity\Attribute;
use RZ\Roadiz\CoreBundle\Entity\Translation;
use Symfony\Component\Form\AbstractType;
Expand All @@ -14,8 +14,12 @@
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class AttributeChoiceType extends AbstractType
final class AttributeChoiceType extends AbstractType
{
public function __construct(private ManagerRegistry $managerRegistry)
{
}

/**
* @inheritDoc
*/
Expand All @@ -28,8 +32,8 @@ function ($dataToForm) {
}
return null;
},
function ($formToData) use ($options) {
return $options['entityManager']->find(Attribute::class, $formToData);
function ($formToData) {
return $this->managerRegistry->getRepository(Attribute::class)->find($formToData);
}
));
}
Expand All @@ -41,14 +45,12 @@ public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);
$resolver->setDefault('empty_data', null);
$resolver->setRequired('entityManager');
$resolver->setAllowedTypes('entityManager', [EntityManagerInterface::class]);
$resolver->setRequired('translation');
$resolver->setAllowedTypes('translation', [Translation::class]);
$resolver->setNormalizer('choices', function (Options $options) {
$choices = [];
/** @var Attribute[] $attributes */
$attributes = $options['entityManager']->getRepository(Attribute::class)->findBy(
$attributes = $this->managerRegistry->getRepository(Attribute::class)->findBy(
[],
['code' => 'ASC']
);
Expand Down
3 changes: 0 additions & 3 deletions src/Form/AttributeValueType.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('attribute', AttributeChoiceType::class, [
'label' => 'attribute_values.form.attribute',
'entityManager' => $options['entityManager'],
'translation' => $options['translation'],
]);
}
Expand All @@ -31,8 +30,6 @@ public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);

$resolver->setRequired('entityManager');
$resolver->setAllowedTypes('entityManager', [EntityManagerInterface::class]);
$resolver->setRequired('translation');
$resolver->setAllowedTypes('translation', [Translation::class]);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Repository/AttributeValueRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public function findByAttributable(
->addSelect('ad')
->addSelect('ag')
->addSelect('agt')
->innerJoin('av.attributeValueTranslations', 'avt')
// We need to fetch values without translations too
->leftJoin('av.attributeValueTranslations', 'avt')
->innerJoin('av.attribute', 'a')
->leftJoin('a.attributeDocuments', 'ad')
->leftJoin('a.attributeTranslations', 'at')
Expand Down

0 comments on commit 72dadc0

Please sign in to comment.