Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SF7] Add Symfony 7 support for Admin bundle #16800

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
use Sylius\Component\User\Repository\UserRepositoryInterface;
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;

final class CreateAdminUserHandler implements MessageHandlerInterface
#[AsMessageHandler]
final class CreateAdminUserHandler
{
/**
* @param UserRepositoryInterface<AdminUserInterface> $adminUserRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (HandlerFailedException $exception) {
$this->io->error(
$exception
->getNestedExceptionOfClass(CreateAdminUserFailedException::class)[0]
->getWrappedExceptions(CreateAdminUserFailedException::class)[0]
->getMessage(),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function it_replaces_decorated_shipment_email_manager_service_of_shipment
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
'sylius.listener.shipment_ship',
0,
'sylius.email_manager.shipment',
new Reference('sylius.email_manager.shipment'),
);
}

Expand All @@ -57,7 +57,7 @@ public function it_does_nothing_if_shipment_email_manager_service_is_not_decorat
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
'sylius.listener.shipment_ship',
0,
'sylius.mailer.shipment_email_manager.admin',
new Reference('sylius.mailer.shipment_email_manager.admin'),
);
}

Expand All @@ -75,7 +75,7 @@ public function it_replaces_decorated_shipment_email_manager_service_of_resend_s
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
ResendShipmentConfirmationEmailAction::class,
1,
ShipmentEmailManagerInterface::class,
new Reference(ShipmentEmailManagerInterface::class),
);
}

Expand All @@ -92,7 +92,7 @@ public function it_does_nothing_if_shipment_email_manager_interface_service_is_n
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
ResendShipmentConfirmationEmailAction::class,
1,
ResendShipmentConfirmationEmailDispatcher::class,
new Reference(ResendShipmentConfirmationEmailDispatcher::class),
);
}

Expand All @@ -110,7 +110,7 @@ public function it_replaces_decorated_order_email_manager_service_of_resend_orde
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
ResendOrderConfirmationEmailAction::class,
1,
OrderEmailManagerInterface::class,
new Reference(OrderEmailManagerInterface::class),
);
}

Expand All @@ -127,7 +127,7 @@ public function it_does_nothing_if_order_email_manager_interface_service_is_not_
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
ResendOrderConfirmationEmailAction::class,
1,
ResendOrderConfirmationEmailDispatcher::class,
new Reference(ResendOrderConfirmationEmailDispatcher::class),
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Sylius/Bundle/AdminBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"twig/twig": "~3.8.0"
},
"require-dev": {
"matthiasnoback/symfony-dependency-injection-test": "^4.2",
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
"php-http/message-factory": "^1.0",
"phpspec/phpspec": "^7.2",
"phpspec/prophecy-phpunit": "^2.0",
Expand All @@ -61,6 +61,9 @@
"extra": {
"branch-alias": {
"dev-main": "2.0-dev"
},
"symfony": {
"require": "7.0.*"
}
},
"autoload": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
use Sylius\Bundle\AdminBundle\Form\Model\PasswordResetRequest;
use Sylius\Bundle\AdminBundle\Form\RequestPasswordResetType;
use Sylius\Bundle\CoreBundle\Command\Admin\Account\RequestResetPasswordEmail;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
Expand Down Expand Up @@ -57,7 +57,7 @@ public function it_sends_reset_password_request_to_message_bus(
RouterInterface $router,
FormInterface $form,
Request $request,
ParameterBagInterface $attributesBag,
ParameterBag $attributesBag,
): void {
$formFactory
->create(RequestPasswordResetType::class)
Expand Down Expand Up @@ -100,7 +100,7 @@ public function it_is_able_to_send_reset_password_request_when_sylius_redirect_p
RouterInterface $router,
FormInterface $form,
Request $request,
ParameterBagInterface $attributesBag,
ParameterBag $attributesBag,
): void {
$formFactory->create(RequestPasswordResetType::class)->willReturn($form);

Expand Down Expand Up @@ -142,7 +142,7 @@ public function it_redirects_to_default_route_if_custom_one_is_not_defined(
RouterInterface $router,
FormInterface $form,
Request $request,
ParameterBagInterface $attributesBag,
ParameterBag $attributesBag,
): void {
$formFactory->create(RequestPasswordResetType::class)->willReturn($form);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Sylius\Bundle\UiBundle\Storage\FilterStorageInterface;
use Symfony\Component\HttpFoundation\InputBag;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\RequestEvent;
Expand All @@ -37,7 +38,6 @@ function it_adds_filter_to_filter_storage(
RequestEvent $event,
Request $request,
ParameterBag $attributes,
ParameterBag $query,
FilterStorageInterface $filterStorage,
): void {
$event->isMainRequest()->willReturn(true);
Expand All @@ -48,7 +48,7 @@ function it_adds_filter_to_filter_storage(
$attributes->get('_controller')->willReturn('Sylius\Bundle\AdminBundle\Controller\ProductController::indexAction');
$request->attributes = $attributes;

$query->all()->willReturn(['filter' => 'foo']);
$query = new InputBag(['filter' => 'foo']);
$request->query = $query;

$filterStorage->all()->willReturn([]);
Expand Down Expand Up @@ -76,7 +76,6 @@ function it_does_not_add_filter_to_filter_storage_if_request_format_is_not_html(
RequestEvent $event,
Request $request,
ParameterBag $attributes,
ParameterBag $query,
FilterStorageInterface $filterStorage,
): void {
$event->isMainRequest()->willReturn(true);
Expand All @@ -87,7 +86,7 @@ function it_does_not_add_filter_to_filter_storage_if_request_format_is_not_html(
$attributes->get('_controller')->willReturn('Sylius\Bundle\AdminBundle\Controller\ProductController::indexAction');
$request->attributes = $attributes;

$query->all()->willReturn(['filter' => 'foo']);
$query = new InputBag(['filter' => 'foo']);
$request->query = $query;

$filterStorage->all()->willReturn([]);
Expand All @@ -103,7 +102,6 @@ function it_does_not_add_filter_to_filter_storage_if_it_is_not_an_admin_section(
RequestEvent $event,
Request $request,
ParameterBag $attributes,
ParameterBag $query,
FilterStorageInterface $filterStorage,
): void {
$event->isMainRequest()->willReturn(true);
Expand All @@ -114,7 +112,7 @@ function it_does_not_add_filter_to_filter_storage_if_it_is_not_an_admin_section(
$attributes->get('_controller')->willReturn('Sylius\Bundle\AdminBundle\Controller\ProductController::indexAction');
$request->attributes = $attributes;

$query->all()->willReturn(['filter' => 'foo']);
$query = new InputBag(['filter' => 'foo']);
$request->query = $query;

$filterStorage->all()->willReturn([]);
Expand All @@ -130,7 +128,6 @@ function it_does_not_add_filter_to_filter_storage_if_controller_is_null(
RequestEvent $event,
Request $request,
ParameterBag $attributes,
ParameterBag $query,
FilterStorageInterface $filterStorage,
): void {
$event->isMainRequest()->willReturn(true);
Expand All @@ -141,7 +138,7 @@ function it_does_not_add_filter_to_filter_storage_if_controller_is_null(
$attributes->get('_controller')->willReturn(null);
$request->attributes = $attributes;

$query->all()->willReturn(['filter' => 'foo']);
$query = new InputBag(['filter' => 'foo']);
$request->query = $query;

$filterStorage->all()->willReturn([]);
Expand All @@ -157,7 +154,6 @@ function it_does_not_add_filter_to_filter_storage_if_route_is_missing(
RequestEvent $event,
Request $request,
ParameterBag $attributes,
ParameterBag $query,
FilterStorageInterface $filterStorage,
): void {
$event->isMainRequest()->willReturn(true);
Expand All @@ -168,7 +164,7 @@ function it_does_not_add_filter_to_filter_storage_if_route_is_missing(
$attributes->get('_controller')->willReturn('Sylius\Bundle\AdminBundle\Controller\ProductController::indexAction');
$request->attributes = $attributes;

$query->all()->willReturn(['filter' => 'foo']);
$query = new InputBag(['filter' => 'foo']);
$request->query = $query;

$filterStorage->all()->willReturn([]);
Expand All @@ -184,7 +180,6 @@ function it_does_not_add_filter_to_filter_storage_if_it_is_not_a_index_resource_
RequestEvent $event,
Request $request,
ParameterBag $attributes,
ParameterBag $query,
FilterStorageInterface $filterStorage,
): void {
$event->isMainRequest()->willReturn(true);
Expand All @@ -195,7 +190,7 @@ function it_does_not_add_filter_to_filter_storage_if_it_is_not_a_index_resource_
$attributes->get('_controller')->willReturn('Sylius\Bundle\AdminBundle\Controller\ProductController::indexAction');
$request->attributes = $attributes;

$query->all()->willReturn(['filter' => 'foo']);
$query = new InputBag(['filter' => 'foo']);
$request->query = $query;

$filterStorage->all()->willReturn([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function it_adds_cache_control_directives_to_admin_requests(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
KernelInterface::MASTER_REQUEST,
KernelInterface::MAIN_REQUEST,
$response->getWrappedObject(),
);

Expand All @@ -79,7 +79,7 @@ function it_does_nothing_if_section_is_different_than_admin(
$event = new ResponseEvent(
$kernel->getWrappedObject(),
$request->getWrappedObject(),
KernelInterface::MASTER_REQUEST,
KernelInterface::MAIN_REQUEST,
$response->getWrappedObject(),
);

Expand Down
Loading