mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
[Money] Deprecate unneeded templating helpers
This commit is contained in:
parent
5596cd38da
commit
310e49a5c5
7 changed files with 119 additions and 2 deletions
|
|
@ -48,3 +48,31 @@
|
|||
+ private ?RouterInterface $router = null,
|
||||
)
|
||||
```
|
||||
|
||||
1. The following templating helpers and its interfaces have been deprecated and will be removed in Sylius 2.0:
|
||||
- `Sylius\Bundle\MoneyBundle\Templating\Helper\ConvertMoneyHelper`
|
||||
- `Sylius\Bundle\MoneyBundle\Templating\Helper\ConvertMoneyHelperInterface`
|
||||
- `Sylius\Bundle\MoneyBundle\Templating\Helper\FormatMoneyHelper`
|
||||
- `Sylius\Bundle\MoneyBundle\Templating\Helper\FormatMoneyHelperInterface`
|
||||
|
||||
1. The following constructor signatures have been changed:
|
||||
|
||||
`Sylius\Bundle\MoneyBundle\Twig\ConvertMoneyExtension`
|
||||
```diff
|
||||
use Sylius\Component\Currency\Converter\CurrencyConverterInterface;
|
||||
|
||||
public function __construct(
|
||||
- private ConvertMoneyHelperInterface $helper,
|
||||
+ private ConvertMoneyHelperInterface|CurrencyConverterInterface $helper,
|
||||
)
|
||||
```
|
||||
|
||||
`Sylius\Bundle\MoneyBundle\Twig\FormatMoneyExtension`
|
||||
```diff
|
||||
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
|
||||
|
||||
public function __construct(
|
||||
- private FormatMoneyHelperInterface $helper,
|
||||
+ private private FormatMoneyHelperInterface|MoneyFormatterInterface $helper,
|
||||
)
|
||||
```
|
||||
|
|
|
|||
|
|
@ -13,9 +13,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\MoneyBundle\Templating\Helper;
|
||||
|
||||
use Sylius\Component\Currency\Converter\CurrencyConverter;
|
||||
use Sylius\Component\Currency\Converter\CurrencyConverterInterface;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'The "%s" class is deprecated, use "%s" instead.',
|
||||
ConvertMoneyHelper::class,
|
||||
CurrencyConverter::class,
|
||||
);
|
||||
|
||||
/** @deprecated since Sylius 1.14 and will be removed in Sylius 2.0. Use {@see \Sylius\Component\Currency\Converter\CurrencyConverter} instead. */
|
||||
class ConvertMoneyHelper extends Helper implements ConvertMoneyHelperInterface
|
||||
{
|
||||
public function __construct(private CurrencyConverterInterface $currencyConverter)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\MoneyBundle\Templating\Helper;
|
||||
|
||||
use Sylius\Component\Currency\Converter\CurrencyConverterInterface;
|
||||
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'The "%s" interface is deprecated, use "%s" instead.',
|
||||
ConvertMoneyHelperInterface::class,
|
||||
CurrencyConverterInterface::class,
|
||||
);
|
||||
|
||||
/** @deprecated since Sylius 1.14 and will be removed in Sylius 2.0. Use {@see \Sylius\Component\Currency\Converter\CurrencyConverterInterface} instead. */
|
||||
interface ConvertMoneyHelperInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,9 +13,19 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\MoneyBundle\Templating\Helper;
|
||||
|
||||
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatter;
|
||||
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
|
||||
use Symfony\Component\Templating\Helper\Helper;
|
||||
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'The "%s" class is deprecated, use "%s" instead.',
|
||||
FormatMoneyHelper::class,
|
||||
MoneyFormatter::class,
|
||||
);
|
||||
|
||||
/** @deprecated since Sylius 1.14 and will be removed in Sylius 2.0. Use {@see \Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatter} instead. */
|
||||
class FormatMoneyHelper extends Helper implements FormatMoneyHelperInterface
|
||||
{
|
||||
public function __construct(private MoneyFormatterInterface $moneyFormatter)
|
||||
|
|
|
|||
|
|
@ -13,6 +13,17 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\MoneyBundle\Templating\Helper;
|
||||
|
||||
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
|
||||
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'The "%s" interface is deprecated, use "%s" instead.',
|
||||
FormatMoneyHelperInterface::class,
|
||||
MoneyFormatterInterface::class,
|
||||
);
|
||||
|
||||
/** @deprecated since Sylius 1.14 and will be removed in Sylius 2.0. Use {@see \Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface} instead. */
|
||||
interface FormatMoneyHelperInterface
|
||||
{
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,17 +14,40 @@ declare(strict_types=1);
|
|||
namespace Sylius\Bundle\MoneyBundle\Twig;
|
||||
|
||||
use Sylius\Bundle\MoneyBundle\Templating\Helper\ConvertMoneyHelperInterface;
|
||||
use Sylius\Component\Currency\Converter\CurrencyConverterInterface;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
final class ConvertMoneyExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(private ConvertMoneyHelperInterface $helper)
|
||||
public function __construct(private ConvertMoneyHelperInterface|CurrencyConverterInterface $helper)
|
||||
{
|
||||
if ($this->helper instanceof ConvertMoneyHelperInterface) {
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'Passing an instance of %s as constructor argument for %s is deprecated and will be prohibited in Sylius 2.0. Pass an instance of %s instead.',
|
||||
ConvertMoneyHelperInterface::class,
|
||||
self::class,
|
||||
CurrencyConverterInterface::class,
|
||||
);
|
||||
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'The argument name $helper is deprecated and will be renamed to $currencyConverter in Sylius 2.0.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getFilters(): array
|
||||
{
|
||||
if ($this->helper instanceof CurrencyConverterInterface) {
|
||||
return [
|
||||
new TwigFilter('sylius_convert_money', [$this->helper, 'convert']),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
new TwigFilter('sylius_convert_money', [$this->helper, 'convertAmount']),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -13,18 +13,42 @@ declare(strict_types=1);
|
|||
|
||||
namespace Sylius\Bundle\MoneyBundle\Twig;
|
||||
|
||||
use Sylius\Bundle\MoneyBundle\Formatter\MoneyFormatterInterface;
|
||||
use Sylius\Bundle\MoneyBundle\Templating\Helper\ConvertMoneyHelperInterface;
|
||||
use Sylius\Bundle\MoneyBundle\Templating\Helper\FormatMoneyHelperInterface;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\TwigFilter;
|
||||
|
||||
final class FormatMoneyExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(private FormatMoneyHelperInterface $helper)
|
||||
public function __construct(private FormatMoneyHelperInterface|MoneyFormatterInterface $helper)
|
||||
{
|
||||
if ($this->helper instanceof ConvertMoneyHelperInterface) {
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'Passing an instance of %s as constructor argument for %s is deprecated and will be prohibited in Sylius 2.0. Pass an instance of %s instead.',
|
||||
FormatMoneyHelperInterface::class,
|
||||
self::class,
|
||||
MoneyFormatterInterface::class,
|
||||
);
|
||||
|
||||
trigger_deprecation(
|
||||
'sylius/money-bundle',
|
||||
'1.14',
|
||||
'The argument name $helper is deprecated and will be renamed to $moneyFormatter in Sylius 2.0.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getFilters(): array
|
||||
{
|
||||
if ($this->helper instanceof MoneyFormatterInterface) {
|
||||
return [
|
||||
new TwigFilter('sylius_format_money', [$this->helper, 'format']),
|
||||
];
|
||||
}
|
||||
|
||||
return [
|
||||
new TwigFilter('sylius_format_money', [$this->helper, 'formatAmount']),
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue