Skip to content

Commit

Permalink
Merge branch 'hotfix/deprecations' into 'release/2.3.0'
Browse files Browse the repository at this point in the history
Fix deprecations in filter factories

See merge request metamodels/core!339
  • Loading branch information
zonky2 committed Sep 25, 2024
2 parents fb64e0f + 2b79797 commit 5ed64dc
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 25 deletions.
13 changes: 13 additions & 0 deletions src/CoreBundle/Resources/config/filter-settings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
services:
metamodels.filter_setting_factory.idlist:
class: MetaModels\Filter\Setting\StaticIdListFilterSettingTypeFactory
arguments:
- '@event_dispatcher'
- '@MetaModels\Filter\FilterUrlBuilder'
- '@translator'
tags:
- { name: metamodels.filter_factory }

Expand All @@ -9,6 +13,7 @@ services:
arguments:
- '@event_dispatcher'
- '@MetaModels\Filter\FilterUrlBuilder'
- '@translator'
tags:
- { name: metamodels.filter_factory }

Expand All @@ -34,10 +39,18 @@ services:

metamodels.filter_setting_factory.conditionand:
class: MetaModels\Filter\Setting\ConditionAndFilterSettingTypeFactory
arguments:
- '@event_dispatcher'
- '@MetaModels\Filter\FilterUrlBuilder'
- '@translator'
tags:
- { name: metamodels.filter_factory }

metamodels.filter_setting_factory.conditionor:
class: MetaModels\Filter\Setting\ConditionOrFilterSettingTypeFactory
arguments:
- '@event_dispatcher'
- '@MetaModels\Filter\FilterUrlBuilder'
- '@translator'
tags:
- { name: metamodels.filter_factory }
24 changes: 22 additions & 2 deletions src/Filter/Setting/ConditionAndFilterSettingTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

namespace MetaModels\Filter\Setting;

use MetaModels\Filter\FilterUrlBuilder;
use MetaModels\Filter\Setting\Condition\ConditionAnd;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Attribute type factory for AND filter settings.
Expand All @@ -31,8 +34,11 @@ class ConditionAndFilterSettingTypeFactory extends AbstractFilterSettingTypeFact
/**
* {@inheritDoc}
*/
public function __construct()
{
public function __construct(
private readonly EventDispatcherInterface $dispatcher,
private readonly FilterUrlBuilder $filterUrlBuilder,
private readonly TranslatorInterface $translator,
) {
parent::__construct();

$this
Expand All @@ -41,4 +47,18 @@ public function __construct()
->setTypeClass(ConditionAnd::class)
->allowAttributeTypes();
}

/**
* {@inheritdoc}
*/
public function createInstance($information, $filterSettings)
{
return new ConditionAnd(
$filterSettings,
$information,
$this->dispatcher,
$this->filterUrlBuilder,
$this->translator
);
}
}
24 changes: 22 additions & 2 deletions src/Filter/Setting/ConditionOrFilterSettingTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@

namespace MetaModels\Filter\Setting;

use MetaModels\Filter\FilterUrlBuilder;
use MetaModels\Filter\Setting\Condition\ConditionOr;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Attribute type factory for OR filter settings.
Expand All @@ -31,8 +34,11 @@ class ConditionOrFilterSettingTypeFactory extends AbstractFilterSettingTypeFacto
/**
* {@inheritDoc}
*/
public function __construct()
{
public function __construct(
private readonly EventDispatcherInterface $dispatcher,
private readonly FilterUrlBuilder $filterUrlBuilder,
private readonly TranslatorInterface $translator,
) {
parent::__construct();

$this
Expand All @@ -41,4 +47,18 @@ public function __construct()
->setTypeClass(ConditionOr::class)
->allowAttributeTypes();
}

/**
* {@inheritdoc}
*/
public function createInstance($information, $filterSettings)
{
return new ConditionOr(
$filterSettings,
$information,
$this->dispatcher,
$this->filterUrlBuilder,
$this->translator
);
}
}
32 changes: 13 additions & 19 deletions src/Filter/Setting/SimpleLookupFilterSettingTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,21 @@

use MetaModels\Filter\FilterUrlBuilder;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Attribute type factory for simple lookup filter settings.
*/
class SimpleLookupFilterSettingTypeFactory extends AbstractFilterSettingTypeFactory
{
/**
* The event dispatcher.
*
* @var EventDispatcherInterface
*/
private $dispatcher;

/**
* The filter URL builder.
*
* @var FilterUrlBuilder
*/
private $filterUrlBuilder;

/**
* {@inheritDoc}
*/
public function __construct(EventDispatcherInterface $dispatcher, FilterUrlBuilder $filterUrlBuilder)
public function __construct(
private readonly EventDispatcherInterface $dispatcher,
private readonly FilterUrlBuilder $filterUrlBuilder,
private readonly TranslatorInterface $translator,
)
{

Check failure on line 40 in src/Filter/Setting/SimpleLookupFilterSettingTypeFactory.php

View workflow job for this annotation

GitHub Actions / PHP: 8.1 Contao: ~4.13.0

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line (reported by phpcs: Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace)

Check failure on line 40 in src/Filter/Setting/SimpleLookupFilterSettingTypeFactory.php

View workflow job for this annotation

GitHub Actions / PHP: 8.2 Contao: ~4.13.0

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line (reported by phpcs: Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace)

Check failure on line 40 in src/Filter/Setting/SimpleLookupFilterSettingTypeFactory.php

View workflow job for this annotation

GitHub Actions / PHP: 8.3 Contao: ~4.13.0

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line (reported by phpcs: Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace)
parent::__construct();

Expand All @@ -54,16 +45,19 @@ public function __construct(EventDispatcherInterface $dispatcher, FilterUrlBuild
->setTypeIcon('bundles/metamodelscore/images/icons/filter_default.png')
->setTypeClass(SimpleLookup::class)
->allowAttributeTypes();

$this->dispatcher = $dispatcher;
$this->filterUrlBuilder = $filterUrlBuilder;
}

/**
* {@inheritdoc}
*/
public function createInstance($information, $filterSettings)
{
return new SimpleLookup($filterSettings, $information, $this->dispatcher, $this->filterUrlBuilder);
return new SimpleLookup(
$filterSettings,
$information,
$this->dispatcher,
$this->filterUrlBuilder,
$this->translator
);
}
}
25 changes: 23 additions & 2 deletions src/Filter/Setting/StaticIdListFilterSettingTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

namespace MetaModels\Filter\Setting;

use MetaModels\Filter\FilterUrlBuilder;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\Translation\TranslatorInterface;

/**
* Attribute type factory for static id list filter settings.
*/
Expand All @@ -29,13 +33,30 @@ class StaticIdListFilterSettingTypeFactory extends AbstractFilterSettingTypeFact
/**
* {@inheritDoc}
*/
public function __construct()
{
public function __construct(
private readonly EventDispatcherInterface $dispatcher,
private readonly FilterUrlBuilder $filterUrlBuilder,
private readonly TranslatorInterface $translator,
) {
parent::__construct();

$this
->setTypeName('idlist')
->setTypeIcon('bundles/metamodelscore/images/icons/filter_default.png')
->setTypeClass(IdList::class);
}

/**
* {@inheritdoc}
*/
public function createInstance($information, $filterSettings)
{
return new IdList(
$filterSettings,
$information,
$this->dispatcher,
$this->filterUrlBuilder,
$this->translator
);
}
}

0 comments on commit 5ed64dc

Please sign in to comment.