Skip to content

Commit

Permalink
Merge pull request #61 from etienne-monsieurbiz/update-version-supports
Browse files Browse the repository at this point in the history
update version supports
  • Loading branch information
delyriand authored Sep 28, 2023
2 parents 55c8c00 + f1f0faa commit 6443d41
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 260 deletions.
17 changes: 2 additions & 15 deletions .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,8 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1']
sylius: ['~1.8.0', '~1.9.0', '~1.10.0', '~1.11.0', '~1.12.0']
exclude:
- php: 8.0
sylius: '~1.8.0'
- php: 8.0
sylius: '~1.9.0'
- php: 8.1
sylius: '~1.8.0'
- php: 8.1
sylius: '~1.9.0'
- php: 7.4
sylius: '~1.11.0'
- php: 7.4
sylius: '~1.12.0'
php: ['8.0', '8.1', '8.2']
sylius: ['~1.10.0', '~1.11.0', '~1.12.0']

steps:
- name: Setup PHP
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1']
php: ['8.0', '8.1', '8.2']

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['8.0', '8.1']
php: ['8.0', '8.1', '8.2']

env:
SYMFONY_ARGS: --no-tls
Expand Down
2 changes: 1 addition & 1 deletion .php-version.dist
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8.1
8.2
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"description": "Add a settings panel to your Sylius.",
"license": "MIT",
"require": {
"php": "~7.4|^8.0",
"php": "^8.0",
"ext-mbstring": "*",
"ext-json": "*",
"sylius/sylius": ">=1.8 <1.13"
"sylius/sylius": ">=1.10 <1.13"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand Down
35 changes: 12 additions & 23 deletions src/Command/SetSettingsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@
use MonsieurBiz\SyliusSettingsPlugin\Settings\SettingsInterface;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Core\Model\ChannelInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
name: 'monsieurbiz:settings:set',
description: 'Set a settings value for a given path',
aliases: ['mbiz:settings:set'],
hidden: false
)]
class SetSettingsCommand extends Command
{
private const ARGUMENT_ALIAS = 'alias';
Expand All @@ -42,38 +49,20 @@ class SetSettingsCommand extends Command

private const ARGUMENT_VALUE = 'value';

private RegistryInterface $settingsRegistry;

private ChannelRepositoryInterface $channelRepository;

private EntityManagerInterface $settingManager;

private SettingsFormatterInterface $settingsFormatter;

private SettingProviderInterface $settingProvider;

protected static $defaultName = 'monsieurbiz:settings:set';

public function __construct(
RegistryInterface $settingsRegistry,
ChannelRepositoryInterface $channelRepository,
EntityManagerInterface $settingManager,
SettingsFormatterInterface $settingsFormatter,
SettingProviderInterface $settingProvider,
private RegistryInterface $settingsRegistry,
private ChannelRepositoryInterface $channelRepository,
private SettingProviderInterface $settingProvider,
private EntityManagerInterface $settingManager,
private SettingsFormatterInterface $settingsFormatter,
string $name = null
) {
$this->settingsRegistry = $settingsRegistry;
$this->channelRepository = $channelRepository;
$this->settingManager = $settingManager;
$this->settingsFormatter = $settingsFormatter;
$this->settingProvider = $settingProvider;
parent::__construct($name);
}

protected function configure(): void
{
$this
->setDescription('Set a settings value for a given path')
->setHelp('This command allows you to set a settings value for a given path')
->addArgument(self::ARGUMENT_ALIAS, InputArgument::REQUIRED, 'Alias of the settings like {vendor}.{plugin} from the setting definition')
->addArgument(self::ARGUMENT_PATH, InputArgument::REQUIRED, 'Path of the settings')
Expand Down
20 changes: 4 additions & 16 deletions src/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,23 @@

final class SettingsController extends AbstractController
{
private SettingsProcessorInterface $settingsProcessor;

private MainSettingsFormTypeFactoryInterface $formFactory;

/**
* SettingsController constructor.
*/
public function __construct(
SettingsProcessorInterface $settingsProcessor,
MainSettingsFormTypeFactoryInterface $formFactory
private SettingsProcessorInterface $settingsProcessor,
private MainSettingsFormTypeFactoryInterface $formFactory
) {
$this->settingsProcessor = $settingsProcessor;
$this->formFactory = $formFactory;
}

/**
* @return Response
*/
public function indexAction(RegistryInterface $registry)
public function indexAction(RegistryInterface $registry): Response
{
return $this->render('@MonsieurBizSyliusSettingsPlugin/Crud/index.html.twig', [
'settings' => $registry->getAllSettings(),
]);
}

/**
* @return Response
*/
public function formAction(Request $request, RegistryInterface $registry, string $alias)
public function formAction(Request $request, RegistryInterface $registry, string $alias): Response
{
if (null === ($settings = $registry->getByAlias($alias))) {
throw $this->createNotFoundException();
Expand Down
15 changes: 3 additions & 12 deletions src/Factory/Form/MainSettingsFormTypeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,14 @@

final class MainSettingsFormTypeFactory implements MainSettingsFormTypeFactoryInterface
{
private FormFactoryInterface $formFactory;

private ChannelRepositoryInterface $channelRepository;

private RepositoryInterface $localeRepository;

/**
* MainSettingsFormTypeFactory constructor.
*/
public function __construct(
FormFactoryInterface $formFactory,
ChannelRepositoryInterface $channelRepository,
RepositoryInterface $localeRepository
private FormFactoryInterface $formFactory,
private ChannelRepositoryInterface $channelRepository,
private RepositoryInterface $localeRepository
) {
$this->formFactory = $formFactory;
$this->channelRepository = $channelRepository;
$this->localeRepository = $localeRepository;
}

public function createNew(SettingsInterface $settings, string $type, array $options = []): FormInterface
Expand Down
13 changes: 2 additions & 11 deletions src/Factory/SettingFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,11 @@

final class SettingFactory implements SettingFactoryInterface
{
/**
* @var string
*/
private $className;

public function __construct(string $className)
public function __construct(private string $className)
{
$this->className = $className;
}

/**
* @return SettingInterface
*/
public function createNew()
public function createNew(): SettingInterface
{
/** @var SettingInterface */
return new $this->className();
Expand Down
20 changes: 4 additions & 16 deletions src/Fixture/Factory/SettingsFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,14 @@

class SettingsFixtureFactory extends AbstractExampleFactory
{
private RegistryInterface $settingsRegistry;

private OptionsResolver $optionsResolver;

private ChannelRepositoryInterface $channelRepository;

private SettingsFormatterInterface $settingsFormatter;

private SettingProviderInterface $settingProvider;

public function __construct(
RegistryInterface $settingsRegistry,
ChannelRepositoryInterface $channelRepository,
SettingsFormatterInterface $settingsFormatter,
SettingProviderInterface $settingProvider
private RegistryInterface $settingsRegistry,
private ChannelRepositoryInterface $channelRepository,
private SettingProviderInterface $settingProvider,
private SettingsFormatterInterface $settingsFormatter
) {
$this->settingsRegistry = $settingsRegistry;
$this->channelRepository = $channelRepository;
$this->settingsFormatter = $settingsFormatter;
$this->settingProvider = $settingProvider;
$this->optionsResolver = new OptionsResolver();

$this->configureOptions($this->optionsResolver);
Expand Down
10 changes: 2 additions & 8 deletions src/Form/MainSettingsType.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@

final class MainSettingsType extends AbstractType implements MainSettingsTypeInterface
{
private ChannelRepositoryInterface $channelRepository;

private RepositoryInterface $localeRepository;

/**
* MainSettingsType constructor.
*/
public function __construct(
ChannelRepositoryInterface $channelRepository,
RepositoryInterface $localeRepository
private ChannelRepositoryInterface $channelRepository,
private RepositoryInterface $localeRepository
) {
$this->channelRepository = $channelRepository;
$this->localeRepository = $localeRepository;
}

public function configureOptions(OptionsResolver $resolver): void
Expand Down
5 changes: 1 addition & 4 deletions src/Formatter/SettingsFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ class SettingsFormatter implements SettingsFormatterInterface
{
/**
* @param int|float|string|array $value
* @param mixed $type
*
* @return mixed
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function formatValue($type, $value)
public function formatValue(mixed $type, $value): mixed
{
switch ($type) {
case SettingInterface::STORAGE_TYPE_BOOLEAN:
Expand Down
5 changes: 1 addition & 4 deletions src/Formatter/SettingsFormatterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ interface SettingsFormatterInterface
{
/**
* @param int|float|string|array $value
* @param mixed $type
*
* @return mixed
*/
public function formatValue($type, $value);
public function formatValue(mixed $type, $value): mixed;
}
8 changes: 1 addition & 7 deletions src/Menu/AdminMenuListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@

final class AdminMenuListener
{
private MenuManipulator $manipulator;

private RegistryInterface $settingsRegistry;

/**
* AdminMenuListener constructor.
*/
public function __construct(MenuManipulator $manipulator, RegistryInterface $settingsRegistry)
public function __construct(private MenuManipulator $manipulator, private RegistryInterface $settingsRegistry)
{
$this->manipulator = $manipulator;
$this->settingsRegistry = $settingsRegistry;
}

public function addAdminMenuItems(MenuBuilderEvent $event): void
Expand Down
15 changes: 3 additions & 12 deletions src/Menu/SettingsFormMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,14 @@

final class SettingsFormMenuBuilder
{
private FactoryInterface $factory;

private ChannelRepositoryInterface $channelRepository;

private RepositoryInterface $localeRepository;

/**
* SettingsFormMenuBuilder constructor.
*/
public function __construct(
FactoryInterface $factory,
ChannelRepositoryInterface $channelRepository,
RepositoryInterface $localeRepository
private FactoryInterface $factory,
private ChannelRepositoryInterface $channelRepository,
private RepositoryInterface $localeRepository
) {
$this->factory = $factory;
$this->channelRepository = $channelRepository;
$this->localeRepository = $localeRepository;
}

public function createMenu(array $options = []): ItemInterface
Expand Down
20 changes: 4 additions & 16 deletions src/Processor/SettingsProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,15 @@

final class SettingsProcessor implements SettingsProcessorInterface
{
private ChannelRepositoryInterface $channelRepository;

private RepositoryInterface $localeRepository;

private EntityManagerInterface $entityManager;

private SettingFactoryInterface $settingFactory;

/**
* SettingsProcessor constructor.
*/
public function __construct(
ChannelRepositoryInterface $channelRepository,
RepositoryInterface $localeRepository,
EntityManagerInterface $entityManager,
SettingFactoryInterface $settingFactory
private ChannelRepositoryInterface $channelRepository,
private RepositoryInterface $localeRepository,
private EntityManagerInterface $entityManager,
private SettingFactoryInterface $settingFactory
) {
$this->channelRepository = $channelRepository;
$this->localeRepository = $localeRepository;
$this->entityManager = $entityManager;
$this->settingFactory = $settingFactory;
}

public function processData(SettingsInterface $settings, array $data): void
Expand Down
Loading

0 comments on commit 6443d41

Please sign in to comment.