*/
- private function getWebServiceStatus(Request $request): array
- {
- $webserviceConfiguration = $this->get('prestashop.admin.webservice.form_data_provider')->getData();
+ private function getWebServiceStatus(
+ Request $request,
+ WebserviceFormDataProvider $webserviceFormDataProvider,
+ ): array {
+ $webserviceConfiguration = $webserviceFormDataProvider->getData();
$webserviceStatus = [
'isEnabled' => (bool) $webserviceConfiguration['enable_webservice'],
'isFunctional' => false,
@@ -384,7 +400,7 @@ private function getWebServiceStatus(Request $request): array
if ($webserviceStatus['isEnabled']) {
$webserviceStatus['endpoint'] = rtrim($request->getSchemeAndHttpHost(), '/');
- $webserviceStatus['endpoint'] .= rtrim($this->getContext()->shop->getBaseURI(), '/');
+ $webserviceStatus['endpoint'] .= rtrim($this->getShopContext()->getBaseURI(), '/');
$webserviceStatus['endpoint'] .= self::WEBSERVICE_ENTRY_ENDPOINT;
$webserviceStatus['isFunctional'] = $this->checkWebserviceEndpoint($webserviceStatus['endpoint']);
}
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/CountryController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/CountryController.php
index 17fca680b8adc..9ff695a27900a 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/CountryController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/CountryController.php
@@ -37,10 +37,14 @@
use PrestaShop\PrestaShop\Core\Domain\Country\Exception\DeleteCountryException;
use PrestaShop\PrestaShop\Core\Domain\Country\Query\GetCountryForEditing;
use PrestaShop\PrestaShop\Core\Domain\Country\QueryResult\CountryForEditing;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface;
use PrestaShop\PrestaShop\Core\Search\Filters\CountryFilters;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -48,7 +52,7 @@
/**
* CountryController is responsible for handling "Improve > International > Locations > Countries"
*/
-class CountryController extends FrameworkBundleAdminController
+class CountryController extends PrestaShopAdminController
{
/**
* Show countries listing page
@@ -59,9 +63,12 @@ class CountryController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function indexAction(Request $request, CountryFilters $filters): Response
- {
- $countryGridFactory = $this->get('prestashop.core.grid.factory.country');
+ public function indexAction(
+ Request $request,
+ CountryFilters $filters,
+ #[Autowire(service: 'prestashop.core.grid.factory.country')]
+ GridFactoryInterface $countryGridFactory
+ ): Response {
$countryGrid = $countryGridFactory->getGrid($filters);
return $this->render('@PrestaShop/Admin/Improve/International/Country/index.html.twig', [
@@ -80,11 +87,13 @@ public function indexAction(Request $request, CountryFilters $filters): Response
* @return Response
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))", redirectRoute: 'admin_countries_index', message: 'You need permission to create new country.')]
- public function createAction(Request $request): Response
- {
- $countryFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.country_form_builder');
- $countryFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.country_form_handler');
-
+ public function createAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.country_form_builder')]
+ FormBuilderInterface $countryFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.country_form_handler')]
+ FormHandlerInterface $countryFormHandler
+ ): Response {
$countryForm = $countryFormBuilder->getForm();
$countryForm->handleRequest($request);
@@ -92,7 +101,7 @@ public function createAction(Request $request): Response
$handleResult = $countryFormHandler->handle($countryForm);
if (null !== $handleResult->getIdentifiableObjectId()) {
- $this->addFlash('success', $this->trans('Successful creation', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful creation', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_countries_index');
}
@@ -104,7 +113,7 @@ public function createAction(Request $request): Response
'countryForm' => $countryForm->createView(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
'enableSidebar' => true,
- 'layoutTitle' => $this->trans('New country', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('New country', [], 'Admin.Navigation.Menu'),
]);
}
@@ -117,25 +126,24 @@ public function createAction(Request $request): Response
* @return Response
*/
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_countries_index', message: 'You need permission to edit this.')]
- public function editAction(int $countryId, Request $request): Response
- {
+ public function editAction(
+ int $countryId,
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.country_form_builder')]
+ FormBuilderInterface $countryFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.country_form_handler')]
+ FormHandlerInterface $countryFormHandler
+ ): Response {
try {
/** @var CountryForEditing $editableCountry */
- $editableCountry = $this->getQueryBus()->handle(new GetCountryForEditing($countryId));
-
- $countryFormBuilder = $this->get(
- 'prestashop.core.form.identifiable_object.builder.country_form_builder'
- );
- $countryFormHandler = $this->get(
- 'prestashop.core.form.identifiable_object.handler.country_form_handler'
- );
+ $editableCountry = $this->dispatchQuery(new GetCountryForEditing($countryId));
$countryForm = $countryFormBuilder->getFormFor($countryId);
$countryForm->handleRequest($request);
$result = $countryFormHandler->handleFor($countryId, $countryForm);
if ($result->isSubmitted() && $result->isValid()) {
- $this->addFlash('success', $this->trans('Successful update', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful update', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_countries_index');
}
@@ -149,7 +157,7 @@ public function editAction(int $countryId, Request $request): Response
'enableSidebar' => true,
'countryForm' => $countryForm->createView(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
- 'countryName' => $editableCountry->getLocalizedNames()[$this->getContextLangId()],
+ 'countryName' => $editableCountry->getLocalizedNames()[$this->getLanguageContext()->getId()],
]);
}
@@ -165,8 +173,8 @@ public function editAction(int $countryId, Request $request): Response
public function deleteAction(int $countryId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new DeleteCountryCommand($countryId));
- $this->addFlash('success', $this->trans('Successful deletion.', 'Admin.Notifications.Success'));
+ $this->dispatchCommand(new DeleteCountryCommand($countryId));
+ $this->addFlash('success', $this->trans('Successful deletion.', [], 'Admin.Notifications.Success'));
} catch (CountryException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -184,7 +192,7 @@ protected function getCountryToolbarButtons(): array
return [
'add' => [
'href' => $this->generateUrl('admin_countries_create'),
- 'desc' => $this->trans('Add new country', 'Admin.International.Feature'),
+ 'desc' => $this->trans('Add new country', [], 'Admin.International.Feature'),
'icon' => 'add_circle_outline',
],
];
@@ -202,24 +210,29 @@ protected function getErrorMessages(Exception $e): array
return [
CountryNotFoundException::class => $this->trans(
'This country does not exist.',
+ [],
'Admin.International.Feature'
),
CannotEditCountryException::class => [
CannotEditCountryException::FAILED_TO_UPDATE_COUNTRY => $this->trans(
'Failed to update country.',
+ [],
'Admin.International.Feature'
),
CannotEditCountryException::UNKNOWN_EXCEPTION => $this->trans(
'Failed to update country. An unexpected error occurred.',
+ [],
'Admin.International.Feature'
),
],
CountryConstraintException::class => $this->trans(
'Country contains invalid field values.',
+ [],
'Admin.International.Feature'
),
DeleteCountryException::class => $this->trans(
'Country cannot be deleted.',
+ [],
'Admin.International.Feature'
),
];
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/CurrencyController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/CurrencyController.php
index 8a102e3012cc9..fc1faa49e97fc 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/CurrencyController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/CurrencyController.php
@@ -49,19 +49,22 @@
use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ExchangeRate as ExchangeRateResult;
use PrestaShop\PrestaShop\Core\Domain\Currency\QueryResult\ReferenceCurrency;
use PrestaShop\PrestaShop\Core\Domain\Currency\ValueObject\ExchangeRate;
+use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface as ConfigurationFormHandlerInterface;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface;
use PrestaShop\PrestaShop\Core\Language\LanguageInterface;
+use PrestaShop\PrestaShop\Core\Language\LanguageRepositoryInterface;
use PrestaShop\PrestaShop\Core\Localization\CLDR\ComputingPrecision;
use PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository as CldrLocaleRepository;
use PrestaShop\PrestaShop\Core\Localization\Currency\PatternTransformer;
-use PrestaShop\PrestaShop\Core\Localization\Locale\Repository as LocaleRepository;
+use PrestaShop\PrestaShop\Core\Localization\Locale\RepositoryInterface as LocaleRepositoryInterface;
use PrestaShop\PrestaShop\Core\Search\Filters\CurrencyFilters;
use PrestaShop\PrestaShop\Core\Security\Permission;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
-use PrestaShopBundle\Entity\Repository\LangRepository;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -70,8 +73,18 @@
/**
* Class CurrencyController is responsible for handling "Improve -> International -> Localization -> Currencies" page.
*/
-class CurrencyController extends FrameworkBundleAdminController
+class CurrencyController extends PrestaShopAdminController
{
+ public static function getSubscribedServices(): array
+ {
+ return parent::getSubscribedServices() + [
+ LanguageRepositoryInterface::class => LanguageRepositoryInterface::class,
+ LocaleRepositoryInterface::class => LocaleRepositoryInterface::class,
+ CldrLocaleRepository::class => CldrLocaleRepository::class,
+ PatternTransformer::class => PatternTransformer::class,
+ ];
+ }
+
/**
* Show currency page.
*
@@ -81,12 +94,17 @@ class CurrencyController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function indexAction(CurrencyFilters $filters, Request $request)
- {
- $currencyGridFactory = $this->get('prestashop.core.grid.factory.currency');
+ public function indexAction(
+ CurrencyFilters $filters,
+ Request $request,
+ #[Autowire(service: 'prestashop.core.grid.factory.currency')]
+ GridFactoryInterface $currencyGridFactory,
+ #[Autowire(service: 'prestashop.admin.currency_settings.form_handler')]
+ ConfigurationFormHandlerInterface $settingsFormHandler
+ ): Response {
$currencyGrid = $currencyGridFactory->getGrid($filters);
- $settingsForm = $this->getSettingsFormHandler()->getForm();
+ $settingsForm = $settingsFormHandler->getForm();
return $this->render('@PrestaShop/Admin/Improve/International/Currency/index.html.twig', [
'currencyGrid' => $this->presentGrid($currencyGrid),
@@ -104,17 +122,20 @@ public function indexAction(CurrencyFilters $filters, Request $request)
* @return Response
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))", redirectRoute: 'admin_currencies_index', message: 'You need permission to create this.')]
- public function createAction(Request $request)
- {
- $multiStoreFeature = $this->get('prestashop.adapter.multistore_feature');
-
- $currencyForm = $this->getCurrencyFormBuilder()->getForm();
+ public function createAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.builder.currency_form_builder')]
+ FormBuilderInterface $currencyFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.currency_form_handler')]
+ FormHandlerInterface $currencyFormHandler,
+ ): Response {
+ $currencyForm = $currencyFormBuilder->getForm();
$currencyForm->handleRequest($request);
try {
- $result = $this->getCurrencyFormHandler()->handle($currencyForm);
+ $result = $currencyFormHandler->handle($currencyForm);
if (null !== $result->getIdentifiableObjectId()) {
- $this->addFlash('success', $this->trans('Successful creation', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful creation', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_currencies_index');
}
@@ -123,9 +144,9 @@ public function createAction(Request $request)
}
return $this->render('@PrestaShop/Admin/Improve/International/Currency/create.html.twig', [
- 'isShopFeatureEnabled' => $multiStoreFeature->isUsed(),
+ 'isShopFeatureEnabled' => $this->getShopContext()->isMultiShopUsed(),
'currencyForm' => $currencyForm->createView(),
- 'layoutTitle' => $this->trans('New currency', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('New currency', [], 'Admin.Navigation.Menu'),
]);
}
@@ -138,18 +159,23 @@ public function createAction(Request $request)
* @return Response
*/
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_currencies_index', message: 'You need permission to edit this.')]
- public function editAction($currencyId, Request $request)
- {
- $multiStoreFeature = $this->get('prestashop.adapter.multistore_feature');
- $currencyForm = $this->getCurrencyFormBuilder()->getFormFor($currencyId);
+ public function editAction(
+ int $currencyId,
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.builder.currency_form_builder')]
+ FormBuilderInterface $currencyFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.currency_form_handler')]
+ FormHandlerInterface $currencyFormHandler,
+ ): Response {
+ $currencyForm = $currencyFormBuilder->getFormFor($currencyId);
try {
$currencyForm->handleRequest($request);
- $result = $this->getCurrencyFormHandler()->handleFor($currencyId, $currencyForm);
+ $result = $currencyFormHandler->handleFor($currencyId, $currencyForm);
if ($result->isSubmitted() && $result->isValid()) {
- $this->addFlash('success', $this->trans('Successful update', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful update', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_currencies_index');
}
@@ -158,14 +184,14 @@ public function editAction($currencyId, Request $request)
}
$templateVars = [
- 'isShopFeatureEnabled' => $multiStoreFeature->isUsed(),
+ 'isShopFeatureEnabled' => $this->getShopContext()->isMultiShopUsed(),
'currencyForm' => $currencyForm->createView(),
'layoutTitle' => $this->trans(
'Editing currency %name%',
- 'Admin.Navigation.Menu',
[
- '%name%' => $currencyForm->getData()['names'][$this->getContextLangId()],
- ]
+ '%name%' => $currencyForm->getData()['names'][$this->getLanguageContext()->getId()],
+ ],
+ 'Admin.Navigation.Menu'
),
];
try {
@@ -184,17 +210,17 @@ public function editAction($currencyId, Request $request)
*
* @return array
*/
- private function getLanguagesData(string $currencyIsoCode)
+ private function getLanguagesData(string $currencyIsoCode): array
{
- /** @var LangRepository $langRepository */
- $langRepository = $this->get('prestashop.core.admin.lang.repository');
+ /** @var LanguageRepositoryInterface $langRepository */
+ $langRepository = $this->container->get(LanguageRepositoryInterface::class);
$languages = $langRepository->findAll();
- /** @var LocaleRepository $localeRepository */
- $localeRepository = $this->get('prestashop.core.localization.locale.repository');
+ /** @var LocaleRepositoryInterface $localeRepository */
+ $localeRepository = $this->container->get(LocaleRepositoryInterface::class);
/** @var CldrLocaleRepository $cldrLocaleRepository */
- $cldrLocaleRepository = $this->get('prestashop.core.localization.cldr.locale_repository');
+ $cldrLocaleRepository = $this->container->get(CldrLocaleRepository::class);
/** @var PatternTransformer $transformer */
- $transformer = $this->get('prestashop.core.localization.currency.pattern_transformer');
+ $transformer = $this->container->get(PatternTransformer::class);
$languagesData = [];
/** @var LanguageInterface $language */
@@ -234,17 +260,17 @@ private function getLanguagesData(string $currencyIsoCode)
*/
#[DemoRestricted(redirectRoute: 'admin_currencies_index')]
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute: 'admin_currencies_index', message: 'You need permission to delete this.')]
- public function deleteAction($currencyId)
+ public function deleteAction(int $currencyId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new DeleteCurrencyCommand((int) $currencyId));
+ $this->dispatchCommand(new DeleteCurrencyCommand((int) $currencyId));
} catch (CurrencyException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
return $this->redirectToRoute('admin_currencies_index');
}
- $this->addFlash('success', $this->trans('Successful deletion', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful deletion', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_currencies_index');
}
@@ -258,26 +284,26 @@ public function deleteAction($currencyId)
*/
#[DemoRestricted(redirectRoute: 'admin_currencies_index')]
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function getReferenceDataAction($currencyIsoCode)
+ public function getReferenceDataAction(string $currencyIsoCode): JsonResponse
{
try {
/** @var ReferenceCurrency $referenceCurrency */
- $referenceCurrency = $this->getQueryBus()->handle(new GetReferenceCurrency($currencyIsoCode));
+ $referenceCurrency = $this->dispatchQuery(new GetReferenceCurrency($currencyIsoCode));
} catch (CurrencyException $e) {
return new JsonResponse([
'error' => $this->trans(
'Cannot find reference data for currency %isoCode%',
- 'Admin.International.Feature',
[
'%isoCode%' => $currencyIsoCode,
- ]
+ ],
+ 'Admin.International.Feature'
),
], 404);
}
try {
/** @var ExchangeRateResult $exchangeRate */
- $exchangeRate = $this->getQueryBus()->handle(new GetCurrencyExchangeRate($currencyIsoCode));
+ $exchangeRate = $this->dispatchQuery(new GetCurrencyExchangeRate($currencyIsoCode));
$computingPrecision = new ComputingPrecision();
$exchangeRateValue = $exchangeRate->getValue()->round($computingPrecision->getPrecision(2));
} catch (ExchangeRateNotFoundException $e) {
@@ -304,10 +330,10 @@ public function getReferenceDataAction($currencyIsoCode)
*/
#[DemoRestricted(redirectRoute: 'admin_currencies_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_currencies_index', message: 'You need permission to edit this.')]
- public function toggleStatusAction($currencyId)
+ public function toggleStatusAction(int $currencyId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new ToggleCurrencyStatusCommand((int) $currencyId));
+ $this->dispatchCommand(new ToggleCurrencyStatusCommand((int) $currencyId));
} catch (CurrencyException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -316,7 +342,7 @@ public function toggleStatusAction($currencyId)
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
return $this->redirectToRoute('admin_currencies_index');
@@ -329,12 +355,12 @@ public function toggleStatusAction($currencyId)
*/
#[DemoRestricted(redirectRoute: 'admin_currencies_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_currencies_index', message: 'You need permission to edit this.')]
- public function refreshExchangeRatesAction()
+ public function refreshExchangeRatesAction(): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new RefreshExchangeRatesCommand());
+ $this->dispatchCommand(new RefreshExchangeRatesCommand());
- $this->addFlash('success', $this->trans('Successful update', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful update', [], 'Admin.Notifications.Success'));
} catch (CannotRefreshExchangeRatesException $exception) {
$this->addFlash('error', $exception->getMessage());
}
@@ -349,8 +375,11 @@ public function refreshExchangeRatesAction()
*
* @return JsonResponse
*/
- public function updateLiveExchangeRatesAction(Request $request)
- {
+ public function updateLiveExchangeRatesAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.currency_settings.form_handler')]
+ ConfigurationFormHandlerInterface $settingsFormHandler
+ ): JsonResponse {
if ($this->isDemoModeEnabled()) {
return $this->json([
'status' => false,
@@ -360,13 +389,14 @@ public function updateLiveExchangeRatesAction(Request $request)
);
}
- $authLevel = $this->authorizationLevel($request->attributes->get('_legacy_controller'));
+ $authLevel = $this->getAuthorizationLevel($request->attributes->get('_legacy_controller'));
if (!in_array($authLevel, [Permission::LEVEL_UPDATE, Permission::LEVEL_DELETE])) {
return $this->json([
'status' => false,
'message' => $this->trans(
'You need permission to edit this.',
+ [],
'Admin.Notifications.Error'
),
],
@@ -374,14 +404,13 @@ public function updateLiveExchangeRatesAction(Request $request)
);
}
- $settingsFormHandler = $this->getSettingsFormHandler();
$settingsForm = $settingsFormHandler->getForm();
$settingsForm->handleRequest($request);
$response = [
'status' => false,
- 'message' => $this->trans('An unexpected error occurred.', 'Admin.Notifications.Error'),
+ 'message' => $this->trans('An unexpected error occurred.', [], 'Admin.Notifications.Error'),
];
$statusCode = Response::HTTP_BAD_REQUEST;
@@ -392,6 +421,7 @@ public function updateLiveExchangeRatesAction(Request $request)
'status' => true,
'message' => $this->trans(
'The status has been successfully updated.',
+ [],
'Admin.Notifications.Success'
),
];
@@ -404,32 +434,6 @@ public function updateLiveExchangeRatesAction(Request $request)
return $this->json($response, $statusCode);
}
- /**
- * Gets form builder.
- *
- * @return FormBuilderInterface
- */
- private function getCurrencyFormBuilder()
- {
- return $this->get('prestashop.core.form.builder.currency_form_builder');
- }
-
- /**
- * @return FormHandlerInterface
- */
- private function getCurrencyFormHandler()
- {
- return $this->get('prestashop.core.form.identifiable_object.currency_form_handler');
- }
-
- /**
- * @return \PrestaShop\PrestaShop\Core\Form\FormHandlerInterface
- */
- private function getSettingsFormHandler()
- {
- return $this->get('prestashop.admin.currency_settings.form_handler');
- }
-
/**
* Toggles currencies status in bulk action
*
@@ -440,20 +444,20 @@ private function getSettingsFormHandler()
*/
#[DemoRestricted(redirectRoute: 'admin_currencies_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_currencies_index')]
- public function bulkToggleStatusAction(Request $request, $status)
+ public function bulkToggleStatusAction(Request $request, string $status): RedirectResponse
{
$currenciesIds = $this->getBulkCurrenciesFromRequest($request);
$expectedStatus = 'enable' === $status;
try {
- $this->getCommandBus()->handle(new BulkToggleCurrenciesStatusCommand(
+ $this->dispatchCommand(new BulkToggleCurrenciesStatusCommand(
$currenciesIds,
$expectedStatus
));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (CurrencyException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -471,16 +475,16 @@ public function bulkToggleStatusAction(Request $request, $status)
*/
#[DemoRestricted(redirectRoute: 'admin_currencies_index')]
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute: 'admin_currencies_index')]
- public function bulkDeleteAction(Request $request)
+ public function bulkDeleteAction(Request $request): RedirectResponse
{
$currenciesIds = $this->getBulkCurrenciesFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkDeleteCurrenciesCommand($currenciesIds));
+ $this->dispatchCommand(new BulkDeleteCurrenciesCommand($currenciesIds));
$this->addFlash(
'success',
- $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success')
+ $this->trans('The selection has been successfully deleted.', [], 'Admin.Notifications.Success')
);
} catch (CurrencyException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -496,7 +500,7 @@ public function bulkDeleteAction(Request $request)
*
* @return array
*/
- private function getErrorMessages(Exception $e)
+ private function getErrorMessages(Exception $e): array
{
$isoCode = $e instanceof InvalidUnofficialCurrencyException ? $e->getIsoCode() : '';
@@ -504,94 +508,102 @@ private function getErrorMessages(Exception $e)
CurrencyConstraintException::class => [
CurrencyConstraintException::INVALID_ISO_CODE => $this->trans(
'The %s field is not valid',
- 'Admin.Notifications.Error',
[
- sprintf('"%s"', $this->trans('ISO code', 'Admin.International.Feature')),
- ]
+ sprintf('"%s"', $this->trans('ISO code', [], 'Admin.International.Feature')),
+ ],
+ 'Admin.Notifications.Error'
),
CurrencyConstraintException::INVALID_NUMERIC_ISO_CODE => $this->trans(
'The %s field is not valid',
- 'Admin.Notifications.Error',
[
- sprintf('"%s"', $this->trans('Numeric ISO code', 'Admin.International.Feature')),
- ]
+ sprintf('"%s"', $this->trans('Numeric ISO code', [], 'Admin.International.Feature')),
+ ],
+ 'Admin.Notifications.Error'
),
CurrencyConstraintException::INVALID_EXCHANGE_RATE => $this->trans(
'The %s field is not valid',
- 'Admin.Notifications.Error',
[
- sprintf('"%s"', $this->trans('Exchange rate', 'Admin.International.Feature')),
- ]
+ sprintf('"%s"', $this->trans('Exchange rate', [], 'Admin.International.Feature')),
+ ],
+ 'Admin.Notifications.Error'
),
CurrencyConstraintException::INVALID_NAME => $this->trans(
'The %s field is not valid',
- 'Admin.Notifications.Error',
[
- sprintf('"%s"', $this->trans('Currency name', 'Admin.International.Feature')),
- ]
+ sprintf('"%s"', $this->trans('Currency name', [], 'Admin.International.Feature')),
+ ],
+ 'Admin.Notifications.Error'
),
CurrencyConstraintException::CURRENCY_ALREADY_EXISTS => $this->trans(
'This currency already exists.',
+ [],
'Admin.International.Notification'
),
CurrencyConstraintException::EMPTY_BULK_TOGGLE => $this->trans(
'You must select at least one item to perform a bulk action.',
+ [],
'Admin.Notifications.Error'
),
CurrencyConstraintException::EMPTY_BULK_DELETE => $this->trans(
'You must select at least one item to perform a bulk action.',
+ [],
'Admin.Notifications.Error'
),
],
DefaultCurrencyInMultiShopException::class => [
DefaultCurrencyInMultiShopException::CANNOT_REMOVE_CURRENCY => $this->trans(
'%currency% is the default currency for shop %shop_name%, and therefore cannot be removed from shop association',
- 'Admin.International.Notification',
[
'%currency%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getCurrencyName() : '',
'%shop_name%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getShopName() : '',
- ]
+ ],
+ 'Admin.International.Notification'
),
DefaultCurrencyInMultiShopException::CANNOT_DISABLE_CURRENCY => $this->trans(
'%currency% is the default currency for shop %shop_name%, and therefore cannot be disabled',
- 'Admin.International.Notification',
[
'%currency%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getCurrencyName() : '',
'%shop_name%' => $e instanceof DefaultCurrencyInMultiShopException ? $e->getShopName() : '',
- ]
+ ],
+ 'Admin.International.Notification'
),
],
CurrencyNotFoundException::class => $this->trans(
'The object cannot be loaded (or found).',
+ [],
'Admin.Notifications.Error'
),
CannotToggleCurrencyException::class => $this->trans(
'An error occurred while updating the status.',
+ [],
'Admin.Notifications.Error'
),
CannotDeleteDefaultCurrencyException::class => $this->trans(
'You cannot delete the default currency',
+ [],
'Admin.International.Notification'
),
CannotDisableDefaultCurrencyException::class => $this->trans(
'You cannot disable the default currency',
+ [],
'Admin.International.Notification'
),
InvalidUnofficialCurrencyException::class => $this->trans(
'Oops... it looks like this ISO code already exists. If you are: [1][2]trying to create an alternative currency, you must type a different ISO code[/2][2]trying to modify the currency with ISO code %isoCode%, make sure you did not check the creation box[/2][/1]',
- 'Admin.International.Notification',
[
'%isoCode%' => $isoCode,
'[1]' => '',
'[2]' => '',
'[/2]' => '',
- ]
+ ],
+ 'Admin.International.Notification'
),
BulkDeleteCurrenciesException::class => sprintf(
'%s: %s',
$this->trans(
'An error occurred while deleting this selection.',
+ [],
'Admin.Notifications.Error'
),
$e instanceof BulkDeleteCurrenciesException ? implode(', ', $e->getCurrenciesNames()) : ''
@@ -600,6 +612,7 @@ private function getErrorMessages(Exception $e)
'%s: %s',
$this->trans(
'An error occurred while updating the status.',
+ [],
'Admin.Notifications.Error'
),
$e instanceof BulkToggleCurrenciesException ? implode(', ', $e->getCurrenciesNames()) : ''
@@ -614,7 +627,7 @@ private function getErrorMessages(Exception $e)
*
* @return int[]
*/
- private function getBulkCurrenciesFromRequest(Request $request)
+ private function getBulkCurrenciesFromRequest(Request $request): array
{
$currenciesIds = $request->request->all('currency_currency_bulk');
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/GeolocationController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/GeolocationController.php
index a5aa06d165042..19ba69320ca8b 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/GeolocationController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/GeolocationController.php
@@ -27,9 +27,11 @@
namespace PrestaShopBundle\Controller\Admin\Improve\International;
use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShop\PrestaShop\Core\Geolocation\GeoLite\GeoLiteCityCheckerInterface;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -37,7 +39,7 @@
/**
* Class GeolocationController is responsible for "Improve > International > Localization > Geolocation" page.
*/
-class GeolocationController extends FrameworkBundleAdminController
+class GeolocationController extends PrestaShopAdminController
{
/**
* Show geolocation page.
@@ -47,17 +49,25 @@ class GeolocationController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message: 'Access denied.')]
- public function indexAction(Request $request)
- {
+ public function indexAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.geolocation.by_ip_address.form_handler')]
+ FormHandlerInterface $geolocationByIpAddressFormHandler,
+ #[Autowire(service: 'prestashop.admin.geolocation.whitelist.form_handler')]
+ FormHandlerInterface $geolocationWhitelistFormHandler,
+ #[Autowire(service: 'prestashop.admin.geolocation.options.form_handler')]
+ FormHandlerInterface $geolocationOptionsFormHandler,
+ #[Autowire(service: 'prestashop.core.geolocation.geo_lite_city.checker')]
+ GeoLiteCityCheckerInterface $geoLiteCityChecker
+ ): Response {
$legacyController = $request->attributes->get('_legacy_controller');
- $geolocationByIpAddressForm = $this->getGeolocationByIpAddressFormHandler()->getForm();
- $geolocationIpAddressWhitelistForm = $this->getGeolocationWhitelistFormHandler()->getForm();
- $geolocationOptionsForm = $this->getGeolocationOptionsFormHandler()->getForm();
- $geoLiteCityChecker = $this->get('prestashop.core.geolocation.geo_lite_city.checker');
+ $geolocationByIpAddressForm = $geolocationByIpAddressFormHandler->getForm();
+ $geolocationIpAddressWhitelistForm = $geolocationWhitelistFormHandler->getForm();
+ $geolocationOptionsForm = $geolocationOptionsFormHandler->getForm();
return $this->render('@PrestaShop/Admin/Improve/International/Geolocation/index.html.twig', [
- 'layoutTitle' => $this->trans('Geolocation', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('Geolocation', [], 'Admin.Navigation.Menu'),
'enableSidebar' => true,
'help_link' => $this->generateSidebarLink($legacyController),
'geolocationByIpAddressForm' => $geolocationByIpAddressForm->createView(),
@@ -76,11 +86,14 @@ public function indexAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_geolocation_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.', redirectRoute: 'admin_geolocation_index')]
- public function processByIpAddressFormAction(Request $request)
- {
+ public function processByIpAddressFormAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.geolocation.by_ip_address.form_handler')]
+ FormHandlerInterface $geolocationByIpAddressFormHandler,
+ ): RedirectResponse {
return $this->processForm(
$request,
- $this->getGeolocationByIpAddressFormHandler(),
+ $geolocationByIpAddressFormHandler,
'ByIpAddress'
);
}
@@ -94,11 +107,14 @@ public function processByIpAddressFormAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_geolocation_index')]
#[AdminSecurity("is_granted('read', request.get('_legacy_controller')) && is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.', redirectRoute: 'admin_geolocation_index')]
- public function processWhitelistFormAction(Request $request)
- {
+ public function processWhitelistFormAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.geolocation.whitelist.form_handler')]
+ FormHandlerInterface $geolocationWhitelistFormHandler,
+ ): RedirectResponse {
return $this->processForm(
$request,
- $this->getGeolocationWhitelistFormHandler(),
+ $geolocationWhitelistFormHandler,
'Whitelist'
);
}
@@ -112,11 +128,14 @@ public function processWhitelistFormAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_geolocation_index')]
#[AdminSecurity("is_granted('read', request.get('_legacy_controller')) && is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.', redirectRoute: 'admin_geolocation_index')]
- public function processOptionsFormAction(Request $request)
- {
+ public function processOptionsFormAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.geolocation.options.form_handler')]
+ FormHandlerInterface $geolocationOptionsFormHandler
+ ): RedirectResponse {
return $this->processForm(
$request,
- $this->getGeolocationOptionsFormHandler(),
+ $geolocationOptionsFormHandler,
'Options'
);
}
@@ -130,14 +149,14 @@ public function processOptionsFormAction(Request $request)
*
* @return RedirectResponse
*/
- protected function processForm(Request $request, FormHandlerInterface $formHandler, string $hookName)
+ protected function processForm(Request $request, FormHandlerInterface $formHandler, string $hookName): RedirectResponse
{
- $this->dispatchHook(
+ $this->dispatchHookWithParameters(
'actionAdminInternationalGeolocationControllerPostProcess' . $hookName . 'Before',
['controller' => $this]
);
- $this->dispatchHook('actionAdminInternationalGeolocationControllerPostProcessBefore', ['controller' => $this]);
+ $this->dispatchHookWithParameters('actionAdminInternationalGeolocationControllerPostProcessBefore', ['controller' => $this]);
$form = $formHandler->getForm();
$form->handleRequest($request);
@@ -147,36 +166,12 @@ protected function processForm(Request $request, FormHandlerInterface $formHandl
$saveErrors = $formHandler->save($data);
if (0 === count($saveErrors)) {
- $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Update successful', [], 'Admin.Notifications.Success'));
} else {
- $this->flashErrors($saveErrors);
+ $this->addFlashErrors($saveErrors);
}
}
return $this->redirectToRoute('admin_geolocation_index');
}
-
- /**
- * @return FormHandlerInterface
- */
- protected function getGeolocationByIpAddressFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.geolocation.by_ip_address.form_handler');
- }
-
- /**
- * @return FormHandlerInterface
- */
- protected function getGeolocationWhitelistFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.geolocation.whitelist.form_handler');
- }
-
- /**
- * @return FormHandlerInterface
- */
- protected function getGeolocationOptionsFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.geolocation.options.form_handler');
- }
}
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/LanguageController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/LanguageController.php
index 3b3f2b9a692fe..abd15a37b6fa7 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/LanguageController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/LanguageController.php
@@ -27,6 +27,7 @@
namespace PrestaShopBundle\Controller\Admin\Improve\International;
use Exception;
+use PrestaShop\PrestaShop\Core\Configuration\IniConfiguration;
use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkDeleteLanguagesCommand;
use PrestaShop\PrestaShop\Core\Domain\Language\Command\BulkToggleLanguagesStatusCommand;
use PrestaShop\PrestaShop\Core\Domain\Language\Command\DeleteLanguageCommand;
@@ -40,13 +41,17 @@
use PrestaShop\PrestaShop\Core\Domain\Language\Exception\LanguageNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\Language\Query\GetLanguageForEditing;
use PrestaShop\PrestaShop\Core\Domain\Language\QueryResult\EditableLanguage;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface;
use PrestaShop\PrestaShop\Core\Image\Uploader\Exception\UploadedImageConstraintException;
use PrestaShop\PrestaShop\Core\Search\Filters\LanguageFilters;
use PrestaShop\PrestaShop\Core\Util\Url\UrlFileCheckerInterface;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Controller\Attribute\AllShopContext;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -55,7 +60,7 @@
* Class LanguageController manages "Improve > International > Localization > Languages".
*/
#[AllShopContext]
-class LanguageController extends FrameworkBundleAdminController
+class LanguageController extends PrestaShopAdminController
{
/**
* Show languages listing page.
@@ -66,20 +71,25 @@ class LanguageController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function indexAction(Request $request, LanguageFilters $filters)
- {
- $languageGridFactory = $this->get('prestashop.core.grid.factory.language');
+ public function indexAction(
+ Request $request,
+ LanguageFilters $filters,
+ #[Autowire(service: 'prestashop.core.grid.factory.language')]
+ GridFactoryInterface $languageGridFactory,
+ UrlFileCheckerInterface $urlFileChecker
+ ): Response {
$languageGrid = $languageGridFactory->getGrid($filters);
return $this->render('@PrestaShop/Admin/Improve/International/Language/index.html.twig', [
'languageGrid' => $this->presentGrid($languageGrid),
- 'isHtaccessFileWriter' => $this->get(UrlFileCheckerInterface::class)->isHtaccessFileWritable(),
+ 'isHtaccessFileWriter' => $urlFileChecker->isHtaccessFileWritable(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
'multistoreInfoTip' => $this->trans(
'Note that this page is available in all shops context only, this is why your context has just switched.',
+ [],
'Admin.Notifications.Info'
),
- 'multistoreIsUsed' => $this->get('prestashop.adapter.multistore_feature')->isUsed(),
+ 'multistoreIsUsed' => $this->getShopContext()->isMultiShopUsed(),
'enableSidebar' => true,
]);
}
@@ -92,11 +102,13 @@ public function indexAction(Request $request, LanguageFilters $filters)
* @return Response
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))")]
- public function createAction(Request $request)
- {
- $languageFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.language_form_handler');
- $languageFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.language_form_builder');
-
+ public function createAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.language_form_builder')]
+ FormBuilderInterface $languageFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.language_form_handler')]
+ FormHandlerInterface $languageFormHandler
+ ): Response {
$languageForm = $languageFormBuilder->getForm();
$languageForm->handleRequest($request);
@@ -104,7 +116,7 @@ public function createAction(Request $request)
$result = $languageFormHandler->handle($languageForm);
if (null !== $result->getIdentifiableObjectId()) {
- $this->addFlash('success', $this->trans('Successful creation', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful creation', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_languages_index');
}
@@ -116,7 +128,7 @@ public function createAction(Request $request)
'languageForm' => $languageForm->createView(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
'enableSidebar' => true,
- 'layoutTitle' => $this->trans('New language', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('New language', [], 'Admin.Navigation.Menu'),
]);
}
@@ -129,11 +141,14 @@ public function createAction(Request $request)
* @return Response
*/
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))")]
- public function editAction($languageId, Request $request)
- {
- $languageFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.language_form_handler');
- $languageFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.language_form_builder');
-
+ public function editAction(
+ int $languageId,
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.language_form_builder')]
+ FormBuilderInterface $languageFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.language_form_handler')]
+ FormHandlerInterface $languageFormHandler
+ ): Response {
try {
$languageForm = $languageFormBuilder->getFormFor((int) $languageId, [], [
'is_for_editing' => true,
@@ -154,7 +169,7 @@ public function editAction($languageId, Request $request)
if ($result->isSubmitted() && $result->isValid()) {
$this->addFlash(
'success',
- $this->trans('Successful update', 'Admin.Notifications.Success')
+ $this->trans('Successful update', [], 'Admin.Notifications.Success')
);
return $this->redirectToRoute('admin_languages_index');
@@ -168,7 +183,7 @@ public function editAction($languageId, Request $request)
}
/** @var EditableLanguage $editableLanguage */
- $editableLanguage = $this->getQueryBus()->handle(new GetLanguageForEditing((int) $languageId));
+ $editableLanguage = $this->dispatchQuery(new GetLanguageForEditing((int) $languageId));
return $this->render('@PrestaShop/Admin/Improve/International/Language/edit.html.twig', [
'languageForm' => $languageForm->createView(),
@@ -177,10 +192,10 @@ public function editAction($languageId, Request $request)
'enableSidebar' => true,
'layoutTitle' => $this->trans(
'Editing language %name%',
- 'Admin.Navigation.Menu',
[
'%name%' => $editableLanguage->getName(),
- ]
+ ],
+ 'Admin.Navigation.Menu'
),
]);
}
@@ -194,12 +209,12 @@ public function editAction($languageId, Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_languages_index')]
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute: 'admin_languages_index')]
- public function deleteAction($languageId)
+ public function deleteAction(int $languageId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new DeleteLanguageCommand((int) $languageId));
+ $this->dispatchCommand(new DeleteLanguageCommand((int) $languageId));
- $this->addFlash('success', $this->trans('Successful deletion', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful deletion', [], 'Admin.Notifications.Success'));
} catch (LanguageException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
}
@@ -216,16 +231,16 @@ public function deleteAction($languageId)
*/
#[DemoRestricted(redirectRoute: 'admin_languages_index')]
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute: 'admin_languages_index')]
- public function bulkDeleteAction(Request $request)
+ public function bulkDeleteAction(Request $request): RedirectResponse
{
$languageIds = $this->getBulkLanguagesFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkDeleteLanguagesCommand($languageIds));
+ $this->dispatchCommand(new BulkDeleteLanguagesCommand($languageIds));
$this->addFlash(
'success',
- $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success')
+ $this->trans('The selection has been successfully deleted.', [], 'Admin.Notifications.Success')
);
} catch (LanguageException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -243,20 +258,20 @@ public function bulkDeleteAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_languages_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_languages_index')]
- public function toggleStatusAction($languageId)
+ public function toggleStatusAction(int $languageId): RedirectResponse
{
try {
/** @var EditableLanguage $editableLanguage */
- $editableLanguage = $this->getQueryBus()->handle(new GetLanguageForEditing((int) $languageId));
+ $editableLanguage = $this->dispatchQuery(new GetLanguageForEditing((int) $languageId));
- $this->getCommandBus()->handle(new ToggleLanguageStatusCommand(
+ $this->dispatchCommand(new ToggleLanguageStatusCommand(
(int) $languageId,
!$editableLanguage->isActive()
));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (LanguageException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -275,20 +290,20 @@ public function toggleStatusAction($languageId)
*/
#[DemoRestricted(redirectRoute: 'admin_languages_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_languages_index')]
- public function bulkToggleStatusAction(Request $request, $status)
+ public function bulkToggleStatusAction(Request $request, string $status): RedirectResponse
{
$languageIds = $this->getBulkLanguagesFromRequest($request);
$expectedStatus = 'enable' === $status;
try {
- $this->getCommandBus()->handle(new BulkToggleLanguagesStatusCommand(
+ $this->dispatchCommand(new BulkToggleLanguagesStatusCommand(
$languageIds,
$expectedStatus
));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (LanguageException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -304,86 +319,103 @@ public function bulkToggleStatusAction(Request $request, $status)
*/
private function getErrorMessages(Exception $e)
{
- $iniConfig = $this->get('prestashop.core.configuration.ini_configuration');
+ $iniConfig = $this->container->get(IniConfiguration::class);
return [
LanguageNotFoundException::class => $this->trans(
'The object cannot be loaded (or found).',
+ [],
'Admin.Notifications.Error'
),
CannotDisableDefaultLanguageException::class => $this->trans(
'You cannot change the status of the default language.',
+ [],
'Admin.International.Notification'
),
UploadedImageConstraintException::class => [
UploadedImageConstraintException::EXCEEDED_SIZE => $this->trans(
- 'Max file size allowed is "%s" bytes.', 'Admin.Notifications.Error', [
+ 'Max file size allowed is "%s" bytes.',
+ [
$iniConfig->getUploadMaxSizeInBytes(),
- ]),
+ ],
+ 'Admin.Notifications.Error'
+ ),
UploadedImageConstraintException::UNRECOGNIZED_FORMAT => $this->trans(
'Image format not recognized, allowed formats are: .gif, .jpg, .png',
+ [],
'Admin.Notifications.Error'
),
],
CopyingNoPictureException::class => [
CopyingNoPictureException::PRODUCT_IMAGE_COPY_ERROR => $this->trans(
'An error occurred while copying "No Picture" image to your product folder.',
+ [],
'Admin.International.Notification'
),
CopyingNoPictureException::CATEGORY_IMAGE_COPY_ERROR => $this->trans(
'An error occurred while copying "No picture" image to your category folder.',
+ [],
'Admin.International.Notification'
),
CopyingNoPictureException::BRAND_IMAGE_COPY_ERROR => $this->trans(
'An error occurred while copying "No picture" image to your brand folder.',
+ [],
'Admin.International.Notification'
),
],
LanguageImageUploadingException::class => [
LanguageImageUploadingException::MEMORY_LIMIT_RESTRICTION => $this->trans(
'Due to memory limit restrictions, this image cannot be loaded. Please increase your memory_limit value via your server\'s configuration settings.',
+ [],
'Admin.Notifications.Error'
),
LanguageImageUploadingException::UNEXPECTED_ERROR => $this->trans(
'An error occurred while uploading the image.',
+ [],
'Admin.Notifications.Error'
),
],
LanguageConstraintException::class => [
LanguageConstraintException::INVALID_ISO_CODE => $this->trans(
'The %s field is invalid.',
- 'Admin.Notifications.Error',
- [sprintf('"%s"', $this->trans('ISO code', 'Admin.International.Feature'))]
+ [sprintf('"%s"', $this->trans('ISO code', [], 'Admin.International.Feature'))],
+ 'Admin.Notifications.Error'
),
LanguageConstraintException::INVALID_IETF_TAG => $this->trans(
'The %s field is invalid.',
- 'Admin.Notifications.Error',
- [sprintf('"%s"', $this->trans('Language code', 'Admin.International.Feature'))]
+ [sprintf('"%s"', $this->trans('Language code', [], 'Admin.International.Feature'))],
+ 'Admin.Notifications.Error'
),
LanguageConstraintException::DUPLICATE_ISO_CODE => $this->trans(
'This ISO code is already linked to another language.',
+ [],
'Admin.International.Notification'
),
LanguageConstraintException::EMPTY_BULK_DELETE => $this->trans(
'You must select at least one element to delete.',
+ [],
'Admin.Notifications.Error'
),
],
DefaultLanguageException::class => [
DefaultLanguageException::CANNOT_DELETE_ERROR => $this->trans(
'You cannot delete the default language.',
+ [],
'Admin.International.Notification'
),
DefaultLanguageException::CANNOT_DISABLE_ERROR => $this->trans(
'You cannot change the status of the default language.',
+ [],
'Admin.International.Notification'
),
DefaultLanguageException::CANNOT_DELETE_DEFAULT_ERROR => $this->trans(
'You cannot delete the default language.',
+ [],
'Admin.International.Notification'
),
DefaultLanguageException::CANNOT_DELETE_IN_USE_ERROR => $this->trans(
'You cannot delete the language currently in use. Please select a different language.',
+ [],
'Admin.International.Notification'
),
],
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/LocalizationController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/LocalizationController.php
index 63325db77262c..39466fe52fa3c 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/LocalizationController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/LocalizationController.php
@@ -28,10 +28,12 @@
use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
use PrestaShop\PrestaShop\Core\Localization\Pack\Import\LocalizationPackImportConfig;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShop\PrestaShop\Core\Localization\Pack\Import\LocalizationPackImporter;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Form\Admin\Improve\International\Localization\ImportLocalizationPackType;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -39,7 +41,7 @@
/**
* Class LocalizationController is responsible for handling "Improve > International > Localization" page.
*/
-class LocalizationController extends FrameworkBundleAdminController
+class LocalizationController extends PrestaShopAdminController
{
/**
* Show localization settings page.
@@ -49,22 +51,29 @@ class LocalizationController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))", message: 'Access denied.')]
- public function indexAction(Request $request)
- {
+ public function indexAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.localization.configuration.form_handler')]
+ FormHandlerInterface $configurationFormHandler,
+ #[Autowire(service: 'prestashop.admin.localization.local_units.form_handler')]
+ FormHandlerInterface $localUnitsFormHandler,
+ #[Autowire(service: 'prestashop.admin.localization.advanced.form_handler')]
+ FormHandlerInterface $advancedFormHandler
+ ): Response {
$legacyController = $request->attributes->get('_legacy_controller');
if (!extension_loaded('openssl')) {
- $this->addFlash('warning', $this->trans('Importing a new language may fail without the OpenSSL module. Please enable "openssl.so" on your server configuration.', 'Admin.International.Notification'));
+ $this->addFlash('warning', $this->trans('Importing a new language may fail without the OpenSSL module. Please enable "openssl.so" on your server configuration.', [], 'Admin.International.Notification'));
}
$localizationPackImportForm = $this->createForm(ImportLocalizationPackType::class);
- $configurationForm = $this->getConfigurationFormHandler()->getForm();
- $localUnitsForm = $this->getLocalUnitsFormHandler()->getForm();
- $advancedForm = $this->getAdvancedFormHandler()->getForm();
+ $configurationForm = $configurationFormHandler->getForm();
+ $localUnitsForm = $localUnitsFormHandler->getForm();
+ $advancedForm = $advancedFormHandler->getForm();
return $this->render('@PrestaShop/Admin/Improve/International/Localization/index.html.twig', [
'layoutHeaderToolbarBtn' => [],
- 'layoutTitle' => $this->trans('Localization', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('Localization', [], 'Admin.Navigation.Menu'),
'enableSidebar' => true,
'help_link' => $this->generateSidebarLink($legacyController),
'configurationForm' => $configurationForm->createView(),
@@ -83,11 +92,14 @@ public function indexAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_localization_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.')]
- public function processConfigurationFormAction(Request $request)
- {
+ public function processConfigurationFormAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.localization.configuration.form_handler')]
+ FormHandlerInterface $configurationFormHandler,
+ ): RedirectResponse {
return $this->processForm(
$request,
- $this->getConfigurationFormHandler(),
+ $configurationFormHandler,
'Configuration'
);
}
@@ -101,11 +113,14 @@ public function processConfigurationFormAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_localization_index')]
#[AdminSecurity("is_granted('read', request.get('_legacy_controller')) && is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.')]
- public function processLocalUnitsFormAction(Request $request)
- {
+ public function processLocalUnitsFormAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.localization.local_units.form_handler')]
+ FormHandlerInterface $localUnitsFormHandler,
+ ): RedirectResponse {
return $this->processForm(
$request,
- $this->getLocalUnitsFormHandler(),
+ $localUnitsFormHandler,
'LocalUnits'
);
}
@@ -119,11 +134,14 @@ public function processLocalUnitsFormAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_localization_index')]
#[AdminSecurity("is_granted('read', request.get('_legacy_controller')) && is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.')]
- public function processAdvancedFormAction(Request $request)
- {
+ public function processAdvancedFormAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.localization.advanced.form_handler')]
+ FormHandlerInterface $advancedFormHandler
+ ): RedirectResponse {
return $this->processForm(
$request,
- $this->getAdvancedFormHandler(),
+ $advancedFormHandler,
'Advanced'
);
}
@@ -137,14 +155,14 @@ public function processAdvancedFormAction(Request $request)
*
* @return RedirectResponse
*/
- protected function processForm(Request $request, FormHandlerInterface $formHandler, string $hookName)
+ protected function processForm(Request $request, FormHandlerInterface $formHandler, string $hookName): RedirectResponse
{
- $this->dispatchHook(
+ $this->dispatchHookWithParameters(
'actionAdminInternationalLocalizationControllerPostProcess' . $hookName . 'Before',
['controller' => $this]
);
- $this->dispatchHook('actionAdminInternationalLocalizationControllerPostProcessBefore', ['controller' => $this]);
+ $this->dispatchHookWithParameters('actionAdminInternationalLocalizationControllerPostProcessBefore', ['controller' => $this]);
$form = $formHandler->getForm();
$form->handleRequest($request);
@@ -154,9 +172,9 @@ protected function processForm(Request $request, FormHandlerInterface $formHandl
$saveErrors = $formHandler->save($data);
if (0 === count($saveErrors)) {
- $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Update successful', [], 'Admin.Notifications.Success'));
} else {
- $this->flashErrors($saveErrors);
+ $this->addFlashErrors($saveErrors);
}
}
@@ -172,8 +190,10 @@ protected function processForm(Request $request, FormHandlerInterface $formHandl
*/
#[DemoRestricted(redirectRoute: 'admin_localization_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.')]
- public function importPackAction(Request $request)
- {
+ public function importPackAction(
+ Request $request,
+ LocalizationPackImporter $localizationPackImporter
+ ): RedirectResponse {
$localizationPackImportForm = $this->createForm(ImportLocalizationPackType::class);
$localizationPackImportForm->handleRequest($request);
@@ -186,13 +206,12 @@ public function importPackAction(Request $request)
$data['download_pack_data']
);
- $localizationPackImporter = $this->get('prestashop.core.localization.pack.import.importer');
$errors = $localizationPackImporter->import($localizationImportConfig);
if (empty($errors)) {
$this->addFlash(
'success',
- $this->trans('Localization pack imported successfully.', 'Admin.International.Notification')
+ $this->trans('Localization pack imported successfully.', [], 'Admin.International.Notification')
);
return $this->redirectToRoute('admin_localization_index');
@@ -205,34 +224,4 @@ public function importPackAction(Request $request)
return $this->redirectToRoute('admin_localization_index');
}
-
- /**
- * Returns localization configuration form handler.
- *
- * @return FormHandlerInterface
- */
- private function getConfigurationFormHandler()
- {
- return $this->get('prestashop.admin.localization.configuration.form_handler');
- }
-
- /**
- * Returns localization local units form handler.
- *
- * @return FormHandlerInterface
- */
- private function getLocalUnitsFormHandler()
- {
- return $this->get('prestashop.admin.localization.local_units.form_handler');
- }
-
- /**
- * Returns localization advanced form handler.
- *
- * @return FormHandlerInterface
- */
- private function getAdvancedFormHandler()
- {
- return $this->get('prestashop.admin.localization.advanced.form_handler');
- }
}
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/StateController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/StateController.php
index 83a202809b02f..e916613244ba1 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/StateController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/StateController.php
@@ -27,6 +27,7 @@
namespace PrestaShopBundle\Controller\Admin\Improve\International;
use Exception;
+use PrestaShop\PrestaShop\Adapter\Form\ChoiceProvider\CountryStateByIdChoiceProvider;
use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryConstraintException;
use PrestaShop\PrestaShop\Core\Domain\Country\Exception\CountryNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\State\Command\BulkDeleteStateCommand;
@@ -44,10 +45,12 @@
use PrestaShop\PrestaShop\Core\Domain\Zone\Exception\ZoneNotFoundException;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface;
use PrestaShop\PrestaShop\Core\Search\Filters\StateFilters;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -57,7 +60,7 @@
/**
* Responsible for handling country states data
*/
-class StateController extends FrameworkBundleAdminController
+class StateController extends PrestaShopAdminController
{
/**
* Provides country states in json response
@@ -66,11 +69,13 @@ class StateController extends FrameworkBundleAdminController
*
* @return JsonResponse
*/
- public function getStatesAction(Request $request)
- {
+ public function getStatesAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.adapter.form.choice_provider.country_state_by_id')]
+ CountryStateByIdChoiceProvider $statesProvider
+ ): JsonResponse {
try {
$countryId = (int) $request->query->get('id_country');
- $statesProvider = $this->get('prestashop.adapter.form.choice_provider.country_state_by_id');
$states = $statesProvider->getChoices([
'id_country' => $countryId,
]);
@@ -96,9 +101,13 @@ public function getStatesAction(Request $request)
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function indexAction(Request $request, StateFilters $filters): Response
- {
- $stateGrid = $this->get('prestashop.core.grid.grid_factory.state')->getGrid($filters);
+ public function indexAction(
+ Request $request,
+ StateFilters $filters,
+ #[Autowire(service: 'prestashop.core.grid.grid_factory.state')]
+ GridFactoryInterface $gridFactory
+ ): Response {
+ $stateGrid = $gridFactory->getGrid($filters);
return $this->render('@PrestaShop/Admin/Improve/International/Locations/State/index.html.twig', [
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
@@ -120,10 +129,10 @@ public function indexAction(Request $request, StateFilters $filters): Response
public function deleteAction(int $stateId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new DeleteStateCommand($stateId));
+ $this->dispatchCommand(new DeleteStateCommand($stateId));
$this->addFlash(
'success',
- $this->trans('Successful deletion', 'Admin.Notifications.Success')
+ $this->trans('Successful deletion', [], 'Admin.Notifications.Success')
);
} catch (StateException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -141,11 +150,17 @@ public function deleteAction(int $stateId): RedirectResponse
* @return Response
*/
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_states_index')]
- public function editAction(int $stateId, Request $request): Response
- {
+ public function editAction(
+ int $stateId,
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.state_form_builder')]
+ FormBuilderInterface $formBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.state_form_handler')]
+ FormHandlerInterface $formHandler
+ ): Response {
try {
/** @var EditableState $editableState */
- $editableState = $this->getQueryBus()->handle(new GetStateForEditing((int) $stateId));
+ $editableState = $this->dispatchQuery(new GetStateForEditing((int) $stateId));
} catch (StateException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -155,11 +170,11 @@ public function editAction(int $stateId, Request $request): Response
$stateForm = null;
try {
- $stateForm = $this->getFormBuilder()->getFormFor((int) $stateId);
+ $stateForm = $formBuilder->getFormFor((int) $stateId);
$stateForm->handleRequest($request);
- $result = $this->getFormHandler()->handleFor((int) $stateId, $stateForm);
+ $result = $formHandler->handleFor((int) $stateId, $stateForm);
if ($result->isSubmitted() && $result->isValid()) {
- $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Update successful', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_states_index');
}
@@ -173,7 +188,7 @@ public function editAction(int $stateId, Request $request): Response
return $this->render('@PrestaShop/Admin/Improve/International/Locations/State/edit.html.twig', [
'enableSidebar' => true,
- 'layoutTitle' => $this->trans('Editing state %value%', 'Admin.Navigation.Menu', ['%value%' => $editableState->getName()]),
+ 'layoutTitle' => $this->trans('Editing state %value%', ['%value%' => $editableState->getName()], 'Admin.Navigation.Menu'),
'stateForm' => $stateForm->createView(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
]);
@@ -187,15 +202,20 @@ public function editAction(int $stateId, Request $request): Response
* @return Response
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))", redirectRoute: 'admin_states_index', message: 'You do not have permission to create this.')]
- public function createAction(Request $request): Response
- {
- $stateForm = $this->getFormBuilder()->getForm();
+ public function createAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.state_form_builder')]
+ FormBuilderInterface $formBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.state_form_handler')]
+ FormHandlerInterface $formHandler
+ ): Response {
+ $stateForm = $formBuilder->getForm();
$stateForm->handleRequest($request);
try {
- $handlerResult = $this->getFormHandler()->handle($stateForm);
+ $handlerResult = $formHandler->handle($stateForm);
if ($handlerResult->isSubmitted() && $handlerResult->isValid()) {
- $this->addFlash('success', $this->trans('Successful creation', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful creation', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_states_index');
}
@@ -209,10 +229,11 @@ public function createAction(Request $request): Response
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
'multistoreInfoTip' => $this->trans(
'Note that this feature is only available in the "all stores" context. It will be added to all your stores.',
+ [],
'Admin.Notifications.Info'
),
- 'multistoreIsUsed' => $this->get('prestashop.adapter.multistore_feature')->isUsed(),
- 'layoutTitle' => $this->trans('New state', 'Admin.Navigation.Menu'),
+ 'multistoreIsUsed' => $this->getShopContext()->isMultiShopUsed(),
+ 'layoutTitle' => $this->trans('New state', [], 'Admin.Navigation.Menu'),
]);
}
@@ -228,13 +249,14 @@ public function createAction(Request $request): Response
public function toggleStatusAction(int $stateId): JsonResponse
{
try {
- $this->getCommandBus()->handle(
+ $this->dispatchCommand(
new ToggleStateStatusCommand((int) $stateId)
);
$response = [
'status' => true,
'message' => $this->trans(
'The status has been successfully updated.',
+ [],
'Admin.Notifications.Success'
),
];
@@ -261,10 +283,10 @@ public function deleteBulkAction(Request $request): RedirectResponse
$stateIds = $this->getBulkStatesFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkDeleteStateCommand($stateIds));
+ $this->dispatchCommand(new BulkDeleteStateCommand($stateIds));
$this->addFlash(
'success',
- $this->trans('Successful deletion', 'Admin.Notifications.Success')
+ $this->trans('Successful deletion', [], 'Admin.Notifications.Success')
);
} catch (StateException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -287,11 +309,11 @@ public function bulkEnableAction(Request $request): RedirectResponse
$stateIds = $this->getBulkStatesFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkToggleStateStatusCommand(true, $stateIds));
+ $this->dispatchCommand(new BulkToggleStateStatusCommand(true, $stateIds));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (StateException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -314,11 +336,11 @@ public function bulkDisableAction(Request $request): RedirectResponse
$stateIds = $this->getBulkStatesFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkToggleStateStatusCommand(false, $stateIds));
+ $this->dispatchCommand(new BulkToggleStateStatusCommand(false, $stateIds));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (StateException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -336,7 +358,7 @@ private function getToolbarButtons(): array
$toolbarButtons['add'] = [
'href' => $this->generateUrl('admin_states_create'),
- 'desc' => $this->trans('Add new state', 'Admin.International.Feature'),
+ 'desc' => $this->trans('Add new state', [], 'Admin.International.Feature'),
'icon' => 'add_circle_outline',
];
@@ -369,60 +391,53 @@ private function getErrorMessages(?Throwable $e = null): array
return [
StateException::class => $this->trans(
'An unexpected error occurred.',
+ [],
'Admin.Notifications.Error'
),
StateNotFoundException::class => $this->trans(
'The object cannot be loaded (or found).',
+ [],
'Admin.Notifications.Error'
),
StateConstraintException::class => [
StateConstraintException::INVALID_ID => $this->trans(
'The object cannot be loaded (the identifier is missing or invalid)',
+ [],
'Admin.Notifications.Error'
),
],
CannotUpdateStateException::class => $this->trans(
'An error occurred while attempting to save.',
+ [],
'Admin.Notifications.Error'
),
CannotAddStateException::class => $this->trans(
'An error occurred while attempting to save.',
+ [],
'Admin.Notifications.Error'
),
ZoneNotFoundException::class => $this->trans(
'The object cannot be loaded (or found).',
+ [],
'Admin.Notifications.Error'
),
CountryNotFoundException::class => $this->trans(
'The object cannot be loaded (or found).',
+ [],
'Admin.Notifications.Error'
),
ZoneException::class => $this->trans(
'The object cannot be loaded (the identifier is missing or invalid)',
+ [],
'Admin.Notifications.Error'
),
CountryConstraintException::class => [
CountryConstraintException::INVALID_ID => $this->trans(
'The object cannot be loaded (the identifier is missing or invalid)',
+ [],
'Admin.Notifications.Error'
),
],
];
}
-
- /**
- * @return FormHandlerInterface
- */
- private function getFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.core.form.identifiable_object.handler.state_form_handler');
- }
-
- /**
- * @return FormBuilderInterface
- */
- private function getFormBuilder(): FormBuilderInterface
- {
- return $this->get('prestashop.core.form.identifiable_object.builder.state_form_builder');
- }
}
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxController.php
index 84118d2991def..6e3940405b563 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxController.php
@@ -37,11 +37,15 @@
use PrestaShop\PrestaShop\Core\Domain\Tax\Exception\UpdateTaxException;
use PrestaShop\PrestaShop\Core\Domain\Tax\Query\GetTaxForEditing;
use PrestaShop\PrestaShop\Core\Domain\Tax\QueryResult\EditableTax;
-use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface as ConfigurationFormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface;
use PrestaShop\PrestaShop\Core\Search\Filters\TaxFilters;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -49,7 +53,7 @@
/**
* Responsible for handling "Improve > International > Taxes" page.
*/
-class TaxController extends FrameworkBundleAdminController
+class TaxController extends PrestaShopAdminController
{
/**
* Show taxes page.
@@ -60,13 +64,18 @@ class TaxController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function indexAction(Request $request, TaxFilters $filters)
- {
+ public function indexAction(
+ Request $request,
+ TaxFilters $filters,
+ #[Autowire(service: 'prestashop.core.grid.factory.tax')]
+ GridFactoryInterface $taxGridFactory,
+ #[Autowire(service: 'prestashop.admin.tax_options.form_handler')]
+ ConfigurationFormHandlerInterface $taxOptionsFormHandler
+ ): Response {
$legacyController = $request->attributes->get('_legacy_controller');
- $taxGridFactory = $this->get('prestashop.core.grid.factory.tax');
$taxGrid = $taxGridFactory->getGrid($filters);
- $taxOptionsForm = $this->getTaxOptionsFormHandler()->getForm();
+ $taxOptionsForm = $taxOptionsFormHandler->getForm();
return $this->render('@PrestaShop/Admin/Improve/International/Tax/index.html.twig', [
'taxGrid' => $this->presentGrid($taxGrid),
@@ -85,10 +94,11 @@ public function indexAction(Request $request, TaxFilters $filters)
*/
#[DemoRestricted(redirectRoute: 'admin_taxes_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller')) && is_granted('create', request.get('_legacy_controller')) && is_granted('delete', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function saveOptionsAction(Request $request)
- {
- $taxOptionsFormHandler = $this->getTaxOptionsFormHandler();
-
+ public function saveOptionsAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.tax_options.form_handler')]
+ ConfigurationFormHandlerInterface $taxOptionsFormHandler
+ ): RedirectResponse {
$taxOptionsForm = $taxOptionsFormHandler->getForm();
$taxOptionsForm->handleRequest($request);
@@ -96,12 +106,12 @@ public function saveOptionsAction(Request $request)
$errors = $taxOptionsFormHandler->save($taxOptionsForm->getData());
if (empty($errors)) {
- $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Update successful', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_taxes_index');
}
- $this->flashErrors($errors);
+ $this->addFlashErrors($errors);
}
return $this->redirectToRoute('admin_taxes_index');
@@ -113,11 +123,13 @@ public function saveOptionsAction(Request $request)
* @return Response
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function createAction(Request $request)
- {
- $taxFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.tax_form_handler');
- $taxFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.tax_form_builder');
-
+ public function createAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.tax_form_builder')]
+ FormBuilderInterface $taxFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.tax_form_handler')]
+ FormHandlerInterface $taxFormHandler
+ ): Response {
try {
$taxForm = $taxFormBuilder->getForm();
} catch (Exception $exception) {
@@ -135,7 +147,7 @@ public function createAction(Request $request)
if (null !== $result->getIdentifiableObjectId()) {
$this->addFlash(
'success',
- $this->trans('Successful creation', 'Admin.Notifications.Success')
+ $this->trans('Successful creation', [], 'Admin.Notifications.Success')
);
return $this->redirectToRoute('admin_taxes_index');
@@ -150,10 +162,11 @@ public function createAction(Request $request)
'enableSidebar' => true,
'multistoreInfoTip' => $this->trans(
'Note that this feature is only available in the "all stores" context. It will be added to all your stores.',
+ [],
'Admin.Notifications.Info'
),
- 'multistoreIsUsed' => $this->get('prestashop.adapter.multistore_feature')->isUsed(),
- 'layoutTitle' => $this->trans('New tax', 'Admin.Navigation.Menu'),
+ 'multistoreIsUsed' => $this->getShopContext()->isMultiShopUsed(),
+ 'layoutTitle' => $this->trans('New tax', [], 'Admin.Navigation.Menu'),
]);
}
@@ -166,11 +179,14 @@ public function createAction(Request $request)
* @return Response
*/
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function editAction(Request $request, $taxId)
- {
- $taxFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.tax_form_handler');
- $taxFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.tax_form_builder');
-
+ public function editAction(
+ Request $request,
+ int $taxId,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.tax_form_builder')]
+ FormBuilderInterface $taxFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.tax_form_handler')]
+ FormHandlerInterface $taxFormHandler
+ ): Response {
try {
$taxForm = $taxFormBuilder->getFormFor((int) $taxId);
} catch (Exception $exception) {
@@ -187,7 +203,7 @@ public function editAction(Request $request, $taxId)
$result = $taxFormHandler->handleFor((int) $taxId, $taxForm);
if ($result->isSubmitted() && $result->isValid()) {
- $this->addFlash('success', $this->trans('Successful update', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful update', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_taxes_index');
}
@@ -200,19 +216,19 @@ public function editAction(Request $request, $taxId)
}
/** @var EditableTax $editableTax */
- $editableTax = $this->getQueryBus()->handle(new GetTaxForEditing((int) $taxId));
+ $editableTax = $this->dispatchQuery(new GetTaxForEditing((int) $taxId));
return $this->render('@PrestaShop/Admin/Improve/International/Tax/edit.html.twig', [
'taxForm' => $taxForm->createView(),
- 'taxName' => $editableTax->getLocalizedNames()[$this->getContextLangId()],
+ 'taxName' => $editableTax->getLocalizedNames()[$this->getLanguageContext()->getId()],
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
'enableSidebar' => true,
'layoutTitle' => $this->trans(
'Editing tax %name%',
- 'Admin.Navigation.Menu',
[
- '%name%' => $editableTax->getLocalizedNames()[$this->getContextLangId()],
- ]
+ '%name%' => $editableTax->getLocalizedNames()[$this->getLanguageContext()->getId()],
+ ],
+ 'Admin.Navigation.Menu'
),
]);
}
@@ -226,13 +242,13 @@ public function editAction(Request $request, $taxId)
*/
#[DemoRestricted(redirectRoute: 'admin_taxes_index')]
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function deleteAction($taxId)
+ public function deleteAction(int $taxId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new DeleteTaxCommand((int) $taxId));
+ $this->dispatchCommand(new DeleteTaxCommand((int) $taxId));
$this->addFlash(
'success',
- $this->trans('Successful deletion', 'Admin.Notifications.Success')
+ $this->trans('Successful deletion', [], 'Admin.Notifications.Success')
);
} catch (TaxException $e) {
}
@@ -249,15 +265,15 @@ public function deleteAction($taxId)
*/
#[DemoRestricted(redirectRoute: 'admin_taxes_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function toggleStatusAction($taxId)
+ public function toggleStatusAction(int $taxId): RedirectResponse
{
try {
/** @var EditableTax $editableTax */
- $editableTax = $this->getQueryBus()->handle(new GetTaxForEditing((int) $taxId));
- $this->getCommandBus()->handle(new ToggleTaxStatusCommand((int) $taxId, !$editableTax->isActive()));
+ $editableTax = $this->dispatchQuery(new GetTaxForEditing((int) $taxId));
+ $this->dispatchCommand(new ToggleTaxStatusCommand((int) $taxId, !$editableTax->isActive()));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (TaxException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -275,14 +291,14 @@ public function toggleStatusAction($taxId)
*/
#[DemoRestricted(redirectRoute: 'admin_taxes_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function bulkEnableStatusAction(Request $request)
+ public function bulkEnableStatusAction(Request $request): RedirectResponse
{
$taxIds = $request->request->all('tax_bulk');
try {
- $this->getCommandBus()->handle(new BulkToggleTaxStatusCommand($taxIds, true));
+ $this->dispatchCommand(new BulkToggleTaxStatusCommand($taxIds, true));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (TaxException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -300,14 +316,14 @@ public function bulkEnableStatusAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_taxes_index')]
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function bulkDisableStatusAction(Request $request)
+ public function bulkDisableStatusAction(Request $request): RedirectResponse
{
$taxIds = $request->request->all('tax_bulk');
try {
- $this->getCommandBus()->handle(new BulkToggleTaxStatusCommand($taxIds, false));
+ $this->dispatchCommand(new BulkToggleTaxStatusCommand($taxIds, false));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (TaxException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -325,14 +341,14 @@ public function bulkDisableStatusAction(Request $request)
*/
#[DemoRestricted(redirectRoute: 'admin_taxes_index')]
#[AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", redirectRoute: 'admin_taxes_index')]
- public function bulkDeleteAction(Request $request)
+ public function bulkDeleteAction(Request $request): RedirectResponse
{
$taxIds = $request->request->all('tax_bulk');
try {
- $this->getCommandBus()->handle(new BulkDeleteTaxCommand($taxIds));
+ $this->dispatchCommand(new BulkDeleteTaxCommand($taxIds));
$this->addFlash(
'success',
- $this->trans('Successful deletion', 'Admin.Notifications.Success')
+ $this->trans('Successful deletion', [], 'Admin.Notifications.Success')
);
} catch (TaxException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -341,14 +357,6 @@ public function bulkDeleteAction(Request $request)
return $this->redirectToRoute('admin_taxes_index');
}
- /**
- * @return FormHandlerInterface
- */
- private function getTaxOptionsFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.tax_options.form_handler');
- }
-
/**
* Gets error messages for exceptions
*
@@ -359,18 +367,21 @@ private function getErrorMessages()
return [
TaxNotFoundException::class => $this->trans(
'The object cannot be loaded (or found).',
+ [],
'Admin.Notifications.Error'
),
UpdateTaxException::class => [
UpdateTaxException::FAILED_BULK_UPDATE_STATUS => [
$this->trans(
'An error occurred while updating the status.',
+ [],
'Admin.Notifications.Error'
),
],
UpdateTaxException::FAILED_UPDATE_STATUS => [
$this->trans(
'An error occurred while updating the status for an object.',
+ [],
'Admin.Notifications.Error'
),
],
@@ -378,10 +389,12 @@ private function getErrorMessages()
DeleteTaxException::class => [
DeleteTaxException::FAILED_BULK_DELETE => $this->trans(
'An error occurred while deleting this selection.',
+ [],
'Admin.Notifications.Error'
),
DeleteTaxException::FAILED_DELETE => $this->trans(
'An error occurred while deleting the object.',
+ [],
'Admin.Notifications.Error'
),
],
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxRulesGroupController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxRulesGroupController.php
index 4074aef12e2f4..fb605bd9a66d2 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxRulesGroupController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/TaxRulesGroupController.php
@@ -42,10 +42,12 @@
use PrestaShop\PrestaShop\Core\Domain\TaxRulesGroup\QueryResult\EditableTaxRulesGroup;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface;
use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface;
use PrestaShop\PrestaShop\Core\Search\Filters\TaxRuleFilters;
use PrestaShop\PrestaShop\Core\Search\Filters\TaxRulesGroupFilters;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -53,7 +55,7 @@
/**
* Responsible for handling "Improve > International > Tax Rules" page.
*/
-class TaxRulesGroupController extends FrameworkBundleAdminController
+class TaxRulesGroupController extends PrestaShopAdminController
{
/**
* Show tax rules group page.
@@ -64,9 +66,12 @@ class TaxRulesGroupController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function indexAction(Request $request, TaxRulesGroupFilters $filters): Response
- {
- $taxRulesGroupGridFactory = $this->get('prestashop.core.grid.factory.tax_rules_group');
+ public function indexAction(
+ Request $request,
+ TaxRulesGroupFilters $filters,
+ #[Autowire(service: 'prestashop.core.grid.factory.tax_rules_group')]
+ GridFactoryInterface $taxRulesGroupGridFactory
+ ): Response {
$taxRulesGroupGrid = $taxRulesGroupGridFactory->getGrid($filters);
return $this->render('@PrestaShop/Admin/Improve/International/TaxRulesGroup/index.html.twig', [
@@ -83,15 +88,20 @@ public function indexAction(Request $request, TaxRulesGroupFilters $filters): Re
* @return Response
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))", redirectRoute: 'admin_tax_rules_groups_index')]
- public function createAction(Request $request): Response
- {
- $taxRulesGroupForm = $this->getFormBuilder()->getForm();
+ public function createAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.tax_rules_group_form_builder')]
+ FormBuilderInterface $formBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.tax_rules_group_form_handler')]
+ FormHandlerInterface $formHandler
+ ): Response {
+ $taxRulesGroupForm = $formBuilder->getForm();
$taxRulesGroupForm->handleRequest($request);
try {
- $handlerResult = $this->getFormHandler()->handle($taxRulesGroupForm);
+ $handlerResult = $formHandler->handle($taxRulesGroupForm);
if ($handlerResult->isSubmitted() && $handlerResult->isValid()) {
- $this->addFlash('success', $this->trans('Successful creation', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful creation', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_tax_rules_groups_edit', [
'taxRulesGroupId' => $handlerResult->getIdentifiableObjectId(),
@@ -105,7 +115,7 @@ public function createAction(Request $request): Response
'enableSidebar' => true,
'taxRulesGroupForm' => $taxRulesGroupForm->createView(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
- 'layoutTitle' => $this->trans('New tax rule', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('New tax rule', [], 'Admin.Navigation.Menu'),
]);
}
@@ -119,16 +129,25 @@ public function createAction(Request $request): Response
* @return Response
*/
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_tax_rules_groups_index')]
- public function editAction(Request $request, int $taxRulesGroupId, TaxRuleFilters $filters): Response
- {
+ public function editAction(
+ Request $request,
+ int $taxRulesGroupId,
+ TaxRuleFilters $filters,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.tax_rules_group_form_builder')]
+ FormBuilderInterface $formBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.tax_rules_group_form_handler')]
+ FormHandlerInterface $formHandler,
+ #[Autowire(service: 'prestashop.core.grid.factory.tax_rule')]
+ GridFactoryInterface $taxRuleGridFactory
+ ): Response {
$taxRulesGroupForm = null;
try {
- $taxRulesGroupForm = $this->getFormBuilder()->getFormFor((int) $taxRulesGroupId);
+ $taxRulesGroupForm = $formBuilder->getFormFor((int) $taxRulesGroupId);
$taxRulesGroupForm->handleRequest($request);
- $result = $this->getFormHandler()->handleFor((int) $taxRulesGroupId, $taxRulesGroupForm);
+ $result = $formHandler->handleFor((int) $taxRulesGroupId, $taxRulesGroupForm);
if ($result->isSubmitted() && $result->isValid()) {
- $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Update successful', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_tax_rules_groups_edit', [
'taxRulesGroupId' => $taxRulesGroupId,
@@ -143,12 +162,11 @@ public function editAction(Request $request, int $taxRulesGroupId, TaxRuleFilter
}
$filters->addFilter(['taxRulesGroupId' => $taxRulesGroupId]);
- $taxRuleGridFactory = $this->get('prestashop.core.grid.factory.tax_rule');
$taxRuleGrid = $taxRuleGridFactory->getGrid($filters);
return $this->render('@PrestaShop/Admin/Improve/International/TaxRulesGroup/edit.html.twig', [
'enableSidebar' => true,
- 'layoutTitle' => $this->trans('Editing tax rule %value%', 'Admin.Navigation.Menu', ['%value%' => $taxRulesGroupForm->getData()['name']]),
+ 'layoutTitle' => $this->trans('Editing tax rule %value%', ['%value%' => $taxRulesGroupForm->getData()['name']], 'Admin.Navigation.Menu'),
'taxRulesGroupForm' => $taxRulesGroupForm->createView(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
'taxRuleGrid' => $this->presentGrid($taxRuleGrid),
@@ -166,10 +184,10 @@ public function editAction(Request $request, int $taxRulesGroupId, TaxRuleFilter
public function deleteAction(int $taxRulesGroupId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new DeleteTaxRulesGroupCommand($taxRulesGroupId));
+ $this->dispatchCommand(new DeleteTaxRulesGroupCommand($taxRulesGroupId));
$this->addFlash(
'success',
- $this->trans('Successful deletion', 'Admin.Notifications.Success')
+ $this->trans('Successful deletion', [], 'Admin.Notifications.Success')
);
} catch (Exception $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -190,17 +208,17 @@ public function toggleStatusAction(int $taxRulesGroupId): RedirectResponse
{
try {
/** @var EditableTaxRulesGroup $editableTaxRulesGroup */
- $editableTaxRulesGroup = $this->getQueryBus()->handle(
+ $editableTaxRulesGroup = $this->dispatchQuery(
new GetTaxRulesGroupForEditing($taxRulesGroupId)
);
- $this->getCommandBus()->handle(
+ $this->dispatchCommand(
new SetTaxRulesGroupStatusCommand($taxRulesGroupId, !$editableTaxRulesGroup->isActive())
);
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (Exception $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
@@ -222,10 +240,10 @@ public function bulkEnableStatusAction(Request $request): RedirectResponse
$taxRulesGroupIds = $this->getBulkTaxRulesGroupFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkSetTaxRulesGroupStatusCommand($taxRulesGroupIds, true));
+ $this->dispatchCommand(new BulkSetTaxRulesGroupStatusCommand($taxRulesGroupIds, true));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (Exception $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -247,10 +265,10 @@ public function bulkDisableStatusAction(Request $request): RedirectResponse
$taxRulesGroupIds = $this->getBulkTaxRulesGroupFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkSetTaxRulesGroupStatusCommand($taxRulesGroupIds, false));
+ $this->dispatchCommand(new BulkSetTaxRulesGroupStatusCommand($taxRulesGroupIds, false));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (Exception $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -272,10 +290,10 @@ public function bulkDeleteAction(Request $request): RedirectResponse
$taxRulesGroupIds = $this->getBulkTaxRulesGroupFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkDeleteTaxRulesGroupCommand($taxRulesGroupIds));
+ $this->dispatchCommand(new BulkDeleteTaxRulesGroupCommand($taxRulesGroupIds));
$this->addFlash(
'success',
- $this->trans('Successful deletion', 'Admin.Notifications.Success')
+ $this->trans('Successful deletion', [], 'Admin.Notifications.Success')
);
} catch (Exception $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -305,7 +323,7 @@ private function getTaxRulesGroupToolbarButtons(): array
$toolbarButtons['add'] = [
'href' => $this->generateUrl('admin_tax_rules_groups_create'),
- 'desc' => $this->trans('Add new tax rule', 'Admin.International.Feature'),
+ 'desc' => $this->trans('Add new tax rule', [], 'Admin.International.Feature'),
'icon' => 'add_circle_outline',
];
@@ -324,15 +342,18 @@ private function getErrorMessages(?Exception $e = null): array
return [
CannotDeleteTaxRulesGroupException::class => $this->trans(
'An error occurred while deleting the object.',
+ [],
'Admin.Notifications.Error'
),
TaxRulesGroupNotFoundException::class => $this->trans(
'The object cannot be loaded (or found).',
+ [],
'Admin.Notifications.Error'
),
CannotUpdateTaxRulesGroupException::class => [
CannotUpdateTaxRulesGroupException::FAILED_TOGGLE_STATUS => $this->trans(
'An error occurred while updating the status.',
+ [],
'Admin.Notifications.Error'
),
],
@@ -340,6 +361,7 @@ private function getErrorMessages(?Exception $e = null): array
'%s: %s',
$this->trans(
'An error occurred while deleting this selection.',
+ [],
'Admin.Notifications.Error'
),
$e instanceof CannotBulkDeleteTaxRulesGroupException ? implode(', ', $e->getTaxRulesGroupsIds()) : ''
@@ -348,6 +370,7 @@ private function getErrorMessages(?Exception $e = null): array
'%s: %s',
$this->trans(
'An error occurred while updating the status.',
+ [],
'Admin.Notifications.Error'
),
$e instanceof CannotBulkUpdateTaxRulesGroupException ? implode(', ', $e->getTaxRulesGroupsIds()) : ''
@@ -355,25 +378,10 @@ private function getErrorMessages(?Exception $e = null): array
TaxRulesGroupConstraintException::class => [
TaxRulesGroupConstraintException::INVALID_ID => $this->trans(
'The object cannot be loaded (the identifier is missing or invalid)',
+ [],
'Admin.Notifications.Error'
),
],
];
}
-
- /**
- * @return FormHandlerInterface
- */
- protected function getFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.core.form.identifiable_object.handler.tax_rules_group_form_handler');
- }
-
- /**
- * @return FormBuilderInterface
- */
- protected function getFormBuilder(): FormBuilderInterface
- {
- return $this->get('prestashop.core.form.identifiable_object.builder.tax_rules_group_form_builder');
- }
}
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/TranslationsController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/TranslationsController.php
index 79fa185f56dbe..8c7a11fcdeca1 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/TranslationsController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/TranslationsController.php
@@ -26,14 +26,22 @@
namespace PrestaShopBundle\Controller\Admin\Improve\International;
-use PrestaShop\PrestaShop\Adapter\Shop\Context;
+use PrestaShop\PrestaShop\Adapter\LegacyContext;
+use PrestaShop\PrestaShop\Adapter\Translations\TranslationRouteFinder;
use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Kpi\Row\HookableKpiRowFactory;
use PrestaShop\PrestaShop\Core\Language\Copier\LanguageCopierConfig;
+use PrestaShop\PrestaShop\Core\Language\Copier\LanguageCopierInterface;
+use PrestaShop\PrestaShop\Core\Language\LanguageRepositoryInterface;
+use PrestaShop\PrestaShop\Core\Language\Pack\Import\LanguagePackImporterInterface;
+use PrestaShop\PrestaShop\Core\Translation\Export\TranslationCatalogueExporter;
use PrestaShop\PrestaShop\Core\Translation\Storage\Provider\Definition\ProviderDefinitionInterface;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Controller\Attribute\AllShopContext;
use PrestaShopBundle\Exception\InvalidModuleException;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
+use PrestaShopBundle\Translation\Exporter\ThemeExporter;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -44,7 +52,7 @@
* Admin controller for the International pages.
*/
#[AllShopContext]
-class TranslationsController extends FrameworkBundleAdminController
+class TranslationsController extends PrestaShopAdminController
{
public const CONTROLLER_NAME = 'ADMINTRANSLATIONS';
@@ -57,11 +65,11 @@ class TranslationsController extends FrameworkBundleAdminController
* Renders the translation page
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function overviewAction()
+ public function overviewAction(): Response
{
return $this->render('@PrestaShop/Admin/Improve/International/Translations/overview.html.twig', [
- 'is_shop_context' => (new Context())->isShopContext(),
- 'layoutTitle' => $this->trans('Translations', 'Admin.Navigation.Menu'),
+ 'is_shop_context' => $this->getShopContext()->getShopConstraint()->isSingleShopContext(),
+ 'layoutTitle' => $this->trans('Translations', [], 'Admin.Navigation.Menu'),
]);
}
@@ -73,16 +81,18 @@ public function overviewAction()
* @return BinaryFileResponse
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function exportThemeAction(Request $request)
- {
+ public function exportThemeAction(
+ Request $request,
+ LanguageRepositoryInterface $langRepository,
+ #[Autowire(service: 'prestashop.translation.theme.exporter')]
+ ThemeExporter $themeExporter
+ ): Response {
$themeName = $request->request->get('theme-name');
$isoCode = $request->request->get('iso_code');
- $langRepository = $this->get('prestashop.core.admin.lang.repository');
- $locale = $langRepository->getLocaleByIsoCode($isoCode);
+ $locale = $langRepository->getOneByIsoCode($isoCode)->getLocale();
- $themeExporter = $this->get('prestashop.translation.theme.exporter');
- $zipFile = $themeExporter->createZipArchive($themeName, $locale, _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR);
+ $zipFile = $themeExporter->createZipArchive($themeName, $locale, true);
$response = new BinaryFileResponse($zipFile);
$response->deleteFileAfterSend(true);
@@ -100,18 +110,28 @@ public function exportThemeAction(Request $request)
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function showSettingsAction(Request $request)
- {
+ public function showSettingsAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.translations_settings.modify_translations.form_handler')]
+ FormHandlerInterface $modifyTranslationsFormHandler,
+ #[Autowire(service: 'prestashop.admin.translations_settings.add_update_language.form_handler')]
+ FormHandlerInterface $addUpdateLanguageFormHandler,
+ #[Autowire(service: 'prestashop.admin.translations_settings.export_catalogues.form_handler')]
+ FormHandlerInterface $exportTranslationCataloguesFormHandler,
+ #[Autowire(service: 'prestashop.admin.translations_settings.copy_language.form_handler')]
+ FormHandlerInterface $copyLanguageFormHandler,
+ LegacyContext $legacyContext,
+ #[Autowire(service: 'prestashop.core.kpi_row.factory.translations_page')]
+ HookableKpiRowFactory $kpiRowFactory
+ ): Response {
$legacyController = $request->attributes->get('_legacy_controller');
- $legacyContext = $this->get('prestashop.adapter.legacy.context');
- $kpiRowFactory = $this->get('prestashop.core.kpi_row.factory.translations_page');
- $modifyTranslationsForm = $this->getModifyTranslationsFormHandler()->getForm();
- $addUpdateLanguageForm = $this->getAddUpdateLanguageTranslationsFormHandler()->getForm();
- $exportCataloguesForm = $this->getExportTranslationCataloguesFormHandler()->getForm();
- $copyLanguageForm = $this->getCopyLanguageTranslationsFormHandler()->getForm();
+ $modifyTranslationsForm = $modifyTranslationsFormHandler->getForm();
+ $addUpdateLanguageForm = $addUpdateLanguageFormHandler->getForm();
+ $exportCataloguesForm = $exportTranslationCataloguesFormHandler->getForm();
+ $copyLanguageForm = $copyLanguageFormHandler->getForm();
return $this->render('@PrestaShop/Admin/Improve/International/Translations/translations_settings.html.twig', [
- 'layoutTitle' => $this->trans('Translations', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('Translations', [], 'Admin.Navigation.Menu'),
'enableSidebar' => true,
'help_link' => $this->generateSidebarLink($legacyController),
'kpiRow' => $kpiRowFactory->build(),
@@ -131,14 +151,16 @@ public function showSettingsAction(Request $request)
* @return RedirectResponse
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function modifyTranslationsAction(Request $request)
- {
+ public function modifyTranslationsAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.adapter.translation_route_finder')]
+ TranslationRouteFinder $routeFinder
+ ): RedirectResponse {
try {
- $routeFinder = $this->get('prestashop.adapter.translation_route_finder');
$route = $routeFinder->findRoute($request);
$routeParameters = $routeFinder->findRouteParameters($request);
} catch (InvalidModuleException $e) {
- $this->addFlash('error', $this->trans('An error has occurred, this module does not exist: %s', 'Admin.International.Notification', [$e->getMessage()]));
+ $this->addFlash('error', $this->trans('An error has occurred, this module does not exist: %s', [$e->getMessage()], 'Admin.International.Notification'));
return $this->redirectToRoute('admin_international_translations_show_settings');
}
@@ -155,9 +177,13 @@ public function modifyTranslationsAction(Request $request)
* @return RedirectResponse
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))")]
- public function addUpdateLanguageAction(Request $request)
- {
- $formHandler = $this->getAddUpdateLanguageTranslationsFormHandler();
+ public function addUpdateLanguageAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.translations_settings.add_update_language.form_handler')]
+ FormHandlerInterface $formHandler,
+ #[Autowire(service: 'prestashop.adapter.language.pack.importer')]
+ LanguagePackImporterInterface $languagePackImporter
+ ): RedirectResponse {
$addUpdateLanguageForm = $formHandler->getForm();
$addUpdateLanguageForm->handleRequest($request);
@@ -165,13 +191,12 @@ public function addUpdateLanguageAction(Request $request)
$data = $addUpdateLanguageForm->getData();
$isoCode = $data['iso_localization_pack'];
- $languagePackImporter = $this->get('prestashop.adapter.language.pack.importer');
$errors = $languagePackImporter->import($isoCode);
if (empty($errors)) {
$this->addFlash(
'success',
- $this->trans('The translations have been successfully added.', 'Admin.International.Notification')
+ $this->trans('The translations have been successfully added.', [], 'Admin.International.Notification')
);
return $this->redirectToRoute('admin_international_translations_show_settings');
@@ -193,9 +218,14 @@ public function addUpdateLanguageAction(Request $request)
* @return BinaryFileResponse|RedirectResponse
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))")]
- public function exportCataloguesAction(Request $request)
- {
- $formHandler = $this->getExportTranslationCataloguesFormHandler();
+ public function exportCataloguesAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.translations_settings.export_catalogues.form_handler')]
+ FormHandlerInterface $formHandler,
+ LanguageRepositoryInterface $langRepository,
+ #[Autowire(service: 'prestashop.translation.export.translation_catalogue')]
+ TranslationCatalogueExporter $translationCatalogueExporter
+ ): BinaryFileResponse|RedirectResponse {
$exportTranslationCataloguesForm = $formHandler->getForm();
$exportTranslationCataloguesForm->handleRequest($request);
@@ -261,16 +291,15 @@ public function exportCataloguesAction(Request $request)
if (empty($selections)) {
$this->addFlash(
'error',
- $this->trans('You must select at least one translation type to export translations.', 'Admin.International.Notification')
+ $this->trans('You must select at least one translation type to export translations.', [], 'Admin.International.Notification')
);
return $this->redirectToRoute('admin_international_translations_show_settings');
}
- $langRepository = $this->get('prestashop.core.admin.lang.repository');
- $locale = $langRepository->getLocaleByIsoCode($isoCode);
+ $locale = $langRepository->getOneByIsoCode($isoCode)->getLocale();
- $zipFilename = $this->get('prestashop.translation.export.translation_catalogue')->export($selections, $locale);
+ $zipFilename = $translationCatalogueExporter->export($selections, $locale);
$response = new BinaryFileResponse($zipFilename);
$response->deleteFileAfterSend(true);
@@ -289,14 +318,17 @@ public function exportCataloguesAction(Request $request)
* @return RedirectResponse
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))")]
- public function copyLanguageAction(Request $request)
- {
- $formHandler = $this->getCopyLanguageTranslationsFormHandler();
+ public function copyLanguageAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.admin.translations_settings.copy_language.form_handler')]
+ FormHandlerInterface $formHandler,
+ #[Autowire(service: 'prestashop.adapter.language.copier')]
+ LanguageCopierInterface $languageCopier
+ ): RedirectResponse {
$form = $formHandler->getForm();
$form->handleRequest($request);
if ($form->isSubmitted()) {
- $languageCopier = $this->get('prestashop.adapter.language.copier');
$data = $form->getData();
$languageCopierConfig = new LanguageCopierConfig(
$data['from_theme'],
@@ -306,47 +338,15 @@ public function copyLanguageAction(Request $request)
);
if ($errors = $languageCopier->copy($languageCopierConfig)) {
- $this->flashErrors($errors);
+ $this->addFlashErrors($errors);
} else {
$this->addFlash(
'success',
- $this->trans('The translation was successfully copied.', 'Admin.International.Notification')
+ $this->trans('The translation was successfully copied.', [], 'Admin.International.Notification')
);
}
}
return $this->redirectToRoute('admin_international_translations_show_settings');
}
-
- /**
- * @return FormHandlerInterface
- */
- private function getModifyTranslationsFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.translations_settings.modify_translations.form_handler');
- }
-
- /**
- * @return FormHandlerInterface
- */
- private function getAddUpdateLanguageTranslationsFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.translations_settings.add_update_language.form_handler');
- }
-
- /**
- * @return FormHandlerInterface
- */
- private function getCopyLanguageTranslationsFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.translations_settings.copy_language.form_handler');
- }
-
- /**
- * @return FormHandlerInterface
- */
- private function getExportTranslationCataloguesFormHandler(): FormHandlerInterface
- {
- return $this->get('prestashop.admin.translations_settings.export_catalogues.form_handler');
- }
}
diff --git a/src/PrestaShopBundle/Controller/Admin/Improve/International/ZoneController.php b/src/PrestaShopBundle/Controller/Admin/Improve/International/ZoneController.php
index 53347b8b73678..a84e45f00d1e8 100644
--- a/src/PrestaShopBundle/Controller/Admin/Improve/International/ZoneController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Improve/International/ZoneController.php
@@ -41,11 +41,16 @@
use PrestaShop\PrestaShop\Core\Domain\Zone\Exception\ZoneNotFoundException;
use PrestaShop\PrestaShop\Core\Domain\Zone\Query\GetZoneForEditing;
use PrestaShop\PrestaShop\Core\Domain\Zone\QueryResult\EditableZone;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Builder\FormBuilderInterface;
+use PrestaShop\PrestaShop\Core\Form\IdentifiableObject\Handler\FormHandlerInterface;
+use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\GridDefinitionFactoryInterface;
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\ZoneGridDefinitionFactory;
+use PrestaShop\PrestaShop\Core\Grid\GridFactoryInterface;
use PrestaShop\PrestaShop\Core\Search\Filters\ZoneFilters;
-use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
+use PrestaShopBundle\Controller\Admin\PrestaShopAdminController;
use PrestaShopBundle\Security\Attribute\AdminSecurity;
use PrestaShopBundle\Security\Attribute\DemoRestricted;
+use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -53,7 +58,7 @@
/**
* ZoneController is responsible for handling "Improve > International > Locations > Zones"
*/
-class ZoneController extends FrameworkBundleAdminController
+class ZoneController extends PrestaShopAdminController
{
/**
* Show all zones.
@@ -64,9 +69,12 @@ class ZoneController extends FrameworkBundleAdminController
* @return Response
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function indexAction(Request $request, ZoneFilters $zoneFilters): Response
- {
- $zoneGridFactory = $this->get('prestashop.core.grid.factory.zone');
+ public function indexAction(
+ Request $request,
+ ZoneFilters $zoneFilters,
+ #[Autowire(service: 'prestashop.core.grid.factory.zone')]
+ GridFactoryInterface $zoneGridFactory
+ ): Response {
$zoneGrid = $zoneGridFactory->getGrid($zoneFilters);
return $this->render('@PrestaShop/Admin/Improve/International/Zone/index.html.twig', [
@@ -85,12 +93,13 @@ public function indexAction(Request $request, ZoneFilters $zoneFilters): Respons
* @return RedirectResponse
*/
#[AdminSecurity("is_granted('read', request.get('_legacy_controller'))")]
- public function searchAction(Request $request): RedirectResponse
- {
- $responseBuilder = $this->get('prestashop.bundle.grid.response_builder');
-
- return $responseBuilder->buildSearchResponse(
- $this->get('prestashop.core.grid.definition.factory.zone'),
+ public function searchAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.grid.definition.factory.zone')]
+ GridDefinitionFactoryInterface $zoneGridDefinitionFactory
+ ): RedirectResponse {
+ return $this->buildSearchResponse(
+ $zoneGridDefinitionFactory,
$request,
ZoneGridDefinitionFactory::GRID_ID,
'admin_zones_index'
@@ -105,11 +114,13 @@ public function searchAction(Request $request): RedirectResponse
* @return Response
*/
#[AdminSecurity("is_granted('create', request.get('_legacy_controller'))", redirectRoute: 'admin_zones_index', message: 'You need permission to create new zone.')]
- public function createAction(Request $request): Response
- {
- $zoneFormBuilder = $this->get('prestashop.core.form.identifiable_object.builder.zone_form_builder');
- $zoneFormHandler = $this->get('prestashop.core.form.identifiable_object.handler.zone_form_handler');
-
+ public function createAction(
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.zone_form_builder')]
+ FormBuilderInterface $zoneFormBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.zone_form_handler')]
+ FormHandlerInterface $zoneFormHandler
+ ): Response {
$zoneForm = $zoneFormBuilder->getForm();
$zoneForm->handleRequest($request);
@@ -117,7 +128,7 @@ public function createAction(Request $request): Response
$handleResult = $zoneFormHandler->handle($zoneForm);
if (null !== $handleResult->getIdentifiableObjectId()) {
- $this->addFlash('success', $this->trans('Successful creation', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Successful creation', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_zones_index');
}
@@ -129,7 +140,7 @@ public function createAction(Request $request): Response
'zoneForm' => $zoneForm->createView(),
'help_link' => $this->generateSidebarLink($request->attributes->get('_legacy_controller')),
'enableSidebar' => true,
- 'layoutTitle' => $this->trans('New zone', 'Admin.Navigation.Menu'),
+ 'layoutTitle' => $this->trans('New zone', [], 'Admin.Navigation.Menu'),
]);
}
@@ -142,14 +153,17 @@ public function createAction(Request $request): Response
* @return Response
*/
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", redirectRoute: 'admin_zones_index', message: 'You need permission to edit this.')]
- public function editAction(int $zoneId, Request $request): Response
- {
+ public function editAction(
+ int $zoneId,
+ Request $request,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.builder.zone_form_builder')]
+ FormBuilderInterface $formBuilder,
+ #[Autowire(service: 'prestashop.core.form.identifiable_object.handler.zone_form_handler')]
+ FormHandlerInterface $formHandler
+ ): Response {
try {
/** @var EditableZone $editableZone */
- $editableZone = $this->getQueryBus()->handle(new GetZoneForEditing($zoneId));
-
- $formBuilder = $this->get('prestashop.core.form.identifiable_object.builder.zone_form_builder');
- $formHandler = $this->get('prestashop.core.form.identifiable_object.handler.zone_form_handler');
+ $editableZone = $this->dispatchQuery(new GetZoneForEditing($zoneId));
$zoneForm = $formBuilder->getFormFor($zoneId);
$zoneForm->handleRequest($request);
@@ -157,7 +171,7 @@ public function editAction(int $zoneId, Request $request): Response
$result = $formHandler->handleFor($zoneId, $zoneForm);
if ($result->isSubmitted() && $result->isValid()) {
- $this->addFlash('success', $this->trans('Update successful', 'Admin.Notifications.Success'));
+ $this->addFlash('success', $this->trans('Update successful', [], 'Admin.Notifications.Success'));
return $this->redirectToRoute('admin_zones_index');
}
@@ -169,10 +183,6 @@ public function editAction(int $zoneId, Request $request): Response
}
}
- if (!isset($zoneForm)) {
- return $this->redirectToRoute('admin_zones_index');
- }
-
return $this->render('@PrestaShop/Admin/Improve/International/Zone/edit.html.twig', [
'zoneName' => $editableZone->getName(),
'zoneForm' => $zoneForm->createView(),
@@ -180,10 +190,10 @@ public function editAction(int $zoneId, Request $request): Response
'enableSidebar' => true,
'layoutTitle' => $this->trans(
'Editing zone %name%',
- 'Admin.Navigation.Menu',
[
'%name%' => $editableZone->getName(),
- ]
+ ],
+ 'Admin.Navigation.Menu'
),
]);
}
@@ -200,8 +210,8 @@ public function editAction(int $zoneId, Request $request): Response
public function deleteAction(int $zoneId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new DeleteZoneCommand($zoneId));
- $this->addFlash('success', $this->trans('Successful deletion', 'Admin.Notifications.Success'));
+ $this->dispatchCommand(new DeleteZoneCommand($zoneId));
+ $this->addFlash('success', $this->trans('Successful deletion', [], 'Admin.Notifications.Success'));
} catch (ZoneException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -223,10 +233,10 @@ public function deleteAction(int $zoneId): RedirectResponse
public function toggleStatusAction(int $zoneId): RedirectResponse
{
try {
- $this->getCommandBus()->handle(new ToggleZoneStatusCommand($zoneId));
+ $this->dispatchCommand(new ToggleZoneStatusCommand($zoneId));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (Exception $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -249,11 +259,11 @@ public function bulkDeleteAction(Request $request): RedirectResponse
$zoneIds = $this->getBulkZonesFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkDeleteZoneCommand($zoneIds));
+ $this->dispatchCommand(new BulkDeleteZoneCommand($zoneIds));
$this->addFlash(
'success',
- $this->trans('The selection has been successfully deleted.', 'Admin.Notifications.Success')
+ $this->trans('The selection has been successfully deleted.', [], 'Admin.Notifications.Success')
);
} catch (ZoneException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -278,10 +288,10 @@ public function bulkToggleStatus(string $status, Request $request): RedirectResp
$zoneIds = $this->getBulkZonesFromRequest($request);
try {
- $this->getCommandBus()->handle(new BulkToggleZoneStatusCommand($status, $zoneIds));
+ $this->dispatchCommand(new BulkToggleZoneStatusCommand($status, $zoneIds));
$this->addFlash(
'success',
- $this->trans('The status has been successfully updated.', 'Admin.Notifications.Success')
+ $this->trans('The status has been successfully updated.', [], 'Admin.Notifications.Success')
);
} catch (ZoneException $e) {
$this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages($e)));
@@ -302,33 +312,38 @@ private function getErrorMessages(Exception $e): array
return [
CannotEditZoneException::class => $this->trans(
'An error occurred while editing the zone.',
+ [],
'Admin.International.Notification'
),
MissingZoneRequiredFieldsException::class => $this->trans(
'The %s field is required.',
- 'Admin.Notifications.Error',
[
implode(
', ',
$e instanceof MissingZoneRequiredFieldsException ? $e->getMissingRequiredFields() : []
),
- ]
+ ],
+ 'Admin.Notifications.Error'
),
ZoneNotFoundException::class => $this->trans(
'This zone does not exist.',
+ [],
'Admin.Notifications.Error'
),
CannotToggleZoneStatusException::class => $this->trans(
'An error occurred while updating the status.',
+ [],
'Admin.Notifications.Error'
),
DeleteZoneException::class => [
DeleteZoneException::FAILED_DELETE => $this->trans(
'An error occurred while deleting the object.',
+ [],
'Admin.Notifications.Error'
),
DeleteZoneException::FAILED_BULK_DELETE => $this->trans(
'An error occurred while deleting this selection.',
+ [],
'Admin.Notifications.Error'
),
],
@@ -357,7 +372,7 @@ private function getZoneToolbarButtons(): array
return [
'add' => [
'href' => $this->generateUrl('admin_zones_create'),
- 'desc' => $this->trans('Add new zone', 'Admin.International.Feature'),
+ 'desc' => $this->trans('Add new zone', [], 'Admin.International.Feature'),
'icon' => 'add_circle_outline',
],
];
diff --git a/src/PrestaShopBundle/Controller/Admin/PrestaShopAdminController.php b/src/PrestaShopBundle/Controller/Admin/PrestaShopAdminController.php
index f9bc4fb7bf475..ecaa480798f34 100644
--- a/src/PrestaShopBundle/Controller/Admin/PrestaShopAdminController.php
+++ b/src/PrestaShopBundle/Controller/Admin/PrestaShopAdminController.php
@@ -38,6 +38,7 @@
use PrestaShop\PrestaShop\Core\Context\LanguageContext;
use PrestaShop\PrestaShop\Core\Context\LegacyControllerContext;
use PrestaShop\PrestaShop\Core\Context\ShopContext;
+use PrestaShop\PrestaShop\Core\EnvironmentInterface;
use PrestaShop\PrestaShop\Core\FeatureFlag\FeatureFlagStateCheckerInterface;
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\GridDefinitionFactoryInterface;
use PrestaShop\PrestaShop\Core\Grid\GridInterface;
@@ -86,6 +87,7 @@ public static function getSubscribedServices(): array
PositionUpdateFactoryInterface::class => PositionUpdateFactoryInterface::class,
GridPositionUpdaterInterface::class => GridPositionUpdaterInterface::class,
FeatureFlagStateCheckerInterface::class => FeatureFlagStateCheckerInterface::class,
+ EnvironmentInterface::class => EnvironmentInterface::class,
];
}
@@ -139,6 +141,11 @@ protected function getShopContext(): ShopContext
return $this->container->get(ShopContext::class);
}
+ protected function getEnvironment(): EnvironmentInterface
+ {
+ return $this->container->get(EnvironmentInterface::class);
+ }
+
/**
* Get commands bus to execute command.
*/
@@ -193,7 +200,7 @@ protected function generateSidebarLink(string $section, ?string $title = null):
*
* @return string
*/
- protected function getErrorMessageForException(Throwable $e, array $messages): string
+ protected function getErrorMessageForException(Throwable $e, array $messages = []): string
{
if ($e instanceof ModuleErrorInterface) {
return $e->getMessage();
diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php
index 8076affbe7424..e7f266701ec37 100644
--- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/CategoryController.php
@@ -37,6 +37,7 @@
use PrestaShop\PrestaShop\Core\Domain\Category\Command\BulkEnableCategoriesCommand;
use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCommand;
use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryCoverImageCommand;
+use PrestaShop\PrestaShop\Core\Domain\Category\Command\DeleteCategoryThumbnailImageCommand;
use PrestaShop\PrestaShop\Core\Domain\Category\Command\SetCategoryIsEnabledCommand;
use PrestaShop\PrestaShop\Core\Domain\Category\Command\UpdateCategoryPositionCommand;
use PrestaShop\PrestaShop\Core\Domain\Category\Exception\CannotAddCategoryException;
@@ -74,7 +75,6 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Class CategoryController is responsible for "Sell > Catalog > Categories" page.
@@ -422,16 +422,35 @@ public function editRootAction(
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.', redirectRoute: 'admin_categories_edit', redirectQueryParamsToKeep: ['categoryId'])]
public function deleteCoverImageAction(Request $request, $categoryId)
{
- if (!$this->isCsrfTokenValid('delete-cover-image', $request->request->get('_csrf_token'))) {
- return $this->redirectToRoute('admin_security_compromised', [
- 'uri' => $this->generateUrl('admin_categories_edit', [
- 'categoryId' => $categoryId,
- ], UrlGeneratorInterface::ABSOLUTE_URL),
- ]);
+ try {
+ $this->dispatchCommand(new DeleteCategoryCoverImageCommand((int) $categoryId));
+
+ $this->addFlash(
+ 'success',
+ $this->trans('Image successfully deleted.', [], 'Admin.Notifications.Success')
+ );
+ } catch (CategoryException $e) {
+ $this->addFlash('error', $this->getErrorMessageForException($e, $this->getErrorMessages()));
}
+ return $this->redirectToRoute('admin_categories_edit', [
+ 'categoryId' => $categoryId,
+ ]);
+ }
+
+ /**
+ * Deletes category thumbnail image.
+ *
+ * @param Request $request
+ * @param int $categoryId
+ *
+ * @return RedirectResponse
+ */
+ #[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.', redirectRoute: 'admin_categories_edit', redirectQueryParamsToKeep: ['categoryId'])]
+ public function deleteThumbnailImageAction(Request $request, $categoryId)
+ {
try {
- $this->dispatchCommand(new DeleteCategoryCoverImageCommand((int) $categoryId));
+ $this->dispatchCommand(new DeleteCategoryThumbnailImageCommand((int) $categoryId));
$this->addFlash(
'success',
diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/ManufacturerController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/ManufacturerController.php
index 0bef5713871d4..dd95a72ee2810 100644
--- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/ManufacturerController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/ManufacturerController.php
@@ -72,7 +72,6 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Manages "Sell > Catalog > Brands & Suppliers > Brands" page
@@ -452,14 +451,6 @@ public function exportAction(
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.', redirectQueryParamsToKeep: ['manufacturerId'], redirectRoute: 'admin_manufacturers_edit')]
public function deleteLogoImageAction(Request $request, int $manufacturerId): RedirectResponse
{
- if (!$this->isCsrfTokenValid('delete-logo-thumbnail', $request->request->get('_csrf_token'))) {
- return $this->redirectToRoute('admin_security_compromised', [
- 'uri' => $this->generateUrl('admin_manufacturers_edit', [
- 'manufacturerId' => $manufacturerId,
- ], UrlGeneratorInterface::ABSOLUTE_URL),
- ]);
- }
-
try {
$this->dispatchCommand(new DeleteManufacturerLogoImageCommand($manufacturerId));
$this->addFlash(
diff --git a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/SupplierController.php b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/SupplierController.php
index 124697eedbd5a..29a11ac4e307e 100644
--- a/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/SupplierController.php
+++ b/src/PrestaShopBundle/Controller/Admin/Sell/Catalog/SupplierController.php
@@ -60,7 +60,6 @@
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
-use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Class SupplierController is responsible for "Sell > Catalog > Brands & Suppliers > Suppliers" page.
@@ -441,14 +440,6 @@ public function exportAction(
#[AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message: 'You do not have permission to edit this.', redirectRoute: 'admin_suppliers_edit', redirectQueryParamsToKeep: ['supplierId'])]
public function deleteLogoImageAction(Request $request, int $supplierId): RedirectResponse
{
- if (!$this->isCsrfTokenValid('delete-logo-thumbnail', $request->request->get('_csrf_token'))) {
- return $this->redirectToRoute('admin_security_compromised', [
- 'uri' => $this->generateUrl('admin_suppliers_edit', [
- 'supplierId' => $supplierId,
- ], UrlGeneratorInterface::ABSOLUTE_URL),
- ]);
- }
-
try {
$this->dispatchCommand(new DeleteSupplierLogoImageCommand($supplierId));
$this->addFlash(
diff --git a/src/PrestaShopBundle/Form/Admin/Catalog/Category/AbstractCategoryType.php b/src/PrestaShopBundle/Form/Admin/Catalog/Category/AbstractCategoryType.php
index 4e1f73e20e0ec..ad6d8b1eb75d3 100644
--- a/src/PrestaShopBundle/Form/Admin/Catalog/Category/AbstractCategoryType.php
+++ b/src/PrestaShopBundle/Form/Admin/Catalog/Category/AbstractCategoryType.php
@@ -180,13 +180,12 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'required' => false,
'can_be_deleted' => true,
'show_size' => true,
- 'csrf_delete_token_id' => 'delete-cover-image',
])
->add('thumbnail_image', ImageWithPreviewType::class, [
'label' => $this->trans('Category thumbnail', 'Admin.Catalog.Feature'),
'help' => $this->trans('It will display a thumbnail on the parent category\'s page, if the theme allows it.', 'Admin.Catalog.Help'),
'required' => false,
- 'can_be_deleted' => false,
+ 'can_be_deleted' => true,
'show_size' => true,
])
->add('seo_preview', CategorySeoPreviewType::class,
diff --git a/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/RequestSql/SqlRequestSettingsType.php b/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/RequestSql/SqlRequestSettingsType.php
index 289a065dfb6e3..062a4334a6c81 100644
--- a/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/RequestSql/SqlRequestSettingsType.php
+++ b/src/PrestaShopBundle/Form/Admin/Configure/AdvancedParameters/RequestSql/SqlRequestSettingsType.php
@@ -30,6 +30,7 @@
use PrestaShopBundle\Form\Admin\Type\SwitchType;
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
+use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
/**
@@ -37,7 +38,7 @@
*/
class SqlRequestSettingsType extends TranslatorAwareType
{
- public function buildForm(FormBuilderInterface $builder, array $options)
+ public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('default_file_encoding', ChoiceType::class, [
@@ -48,13 +49,20 @@ public function buildForm(FormBuilderInterface $builder, array $options)
],
'translation_domain' => false,
])
+ ->add('default_file_separator', TextType::class, [
+ 'label' => $this->trans('Select your default file separator', 'Admin.Advparameters.Feature'),
+ 'translation_domain' => false,
+ 'attr' => [
+ 'maxlength' => '1',
+ 'required',
+ ],
+ ])
->add('enable_multi_statements', SwitchType::class, [
'label' => $this->trans('Enable multi-statements queries', 'Admin.Advparameters.Feature'),
'help' => $this->trans(
'Enabling multi-statements queries increases the risk of SQL injection vulnerabilities being exploited.',
'Admin.Advparameters.Help'
),
- ])
- ;
+ ]);
}
}
diff --git a/src/PrestaShopBundle/Form/Admin/Sell/Product/ProductSearchAndResetType.php b/src/PrestaShopBundle/Form/Admin/Sell/Product/ProductSearchAndResetType.php
new file mode 100644
index 0000000000000..91687c847ca32
--- /dev/null
+++ b/src/PrestaShopBundle/Form/Admin/Sell/Product/ProductSearchAndResetType.php
@@ -0,0 +1,50 @@
+
+ * @copyright Since 2007 PrestaShop SA and Contributors
+ * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
+ */
+
+namespace PrestaShopBundle\Form\Admin\Sell\Product;
+
+use PrestaShopBundle\Form\Admin\Type\SearchAndResetType;
+use Symfony\Component\Form\FormInterface;
+use Symfony\Component\Form\FormView;
+
+/**
+ * Special search and reset button for product grid, the reset button is not shown when
+ * category is the only filter selected.
+ */
+class ProductSearchAndResetType extends SearchAndResetType
+{
+ public function buildView(FormView $view, FormInterface $form, array $options)
+ {
+ parent::buildView($view, $form, $options);
+ if (null !== $form->getParent()) {
+ $selectedFilters = array_keys($form->getParent()->getData());
+
+ if (count($selectedFilters) === 1 && $selectedFilters[0] === 'id_category') {
+ $view->vars['show_reset_button'] = false;
+ }
+ }
+ }
+}
diff --git a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/categories.yml b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/categories.yml
index ce433f89b5cc2..b0e2ae7677b92 100644
--- a/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/categories.yml
+++ b/src/PrestaShopBundle/Resources/config/routing/admin/sell/catalog/categories.yml
@@ -127,6 +127,15 @@ admin_categories_delete_cover_image:
requirements:
categoryId: \d+
+admin_categories_delete_thumbnail_image:
+ path: /{categoryId}/delete-thumbnail-image
+ methods: [ POST ]
+ defaults:
+ _controller: PrestaShopBundle\Controller\Admin\Sell\Catalog\CategoryController::deleteThumbnailImageAction
+ _legacy_controller: AdminCategories
+ requirements:
+ categoryId: \d+
+
admin_categories_update_position:
path: /update-positions
methods: [ POST ]
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/backup.yml b/src/PrestaShopBundle/Resources/config/services/adapter/backup.yml
index 3019101f3df5b..cd430980fef66 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/backup.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/backup.yml
@@ -2,7 +2,7 @@ services:
_defaults:
autowire: true
- PrestaShop\PrestaShop\Core\Backup\BackupInterface:
+ PrestaShop\PrestaShop\Core\Backup\Manager\BackupCreatorInterface:
class: PrestaShop\PrestaShop\Adapter\Backup\DatabaseBackupCreator
public: true
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/category.yml b/src/PrestaShopBundle/Resources/config/services/adapter/category.yml
index ba7e16a0dee3b..a797ebbe0cc9e 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/category.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/category.yml
@@ -79,8 +79,13 @@ services:
arguments:
- '@prestashop.core.image.parser.image_tag_source_parser'
- prestashop.adapter.category.command_handler.delete_category_cover_image_handler:
- class: PrestaShop\PrestaShop\Adapter\Category\CommandHandler\DeleteCategoryCoverImageHandler
+ PrestaShop\PrestaShop\Adapter\Category\CommandHandler\DeleteCategoryCoverImageHandler:
+ autoconfigure: true
+ arguments:
+ - '@filesystem'
+ - '@prestashop.adapter.legacy.configuration'
+
+ PrestaShop\PrestaShop\Adapter\Category\CommandHandler\DeleteCategoryThumbnailImageHandler:
autoconfigure: true
arguments:
- '@filesystem'
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/data_configuration.yml b/src/PrestaShopBundle/Resources/config/services/adapter/data_configuration.yml
index 9d7cc2848b954..f1428293732ba 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/data_configuration.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/data_configuration.yml
@@ -52,6 +52,7 @@ services:
- '%ps_config_dir%/defines.inc.php'
- '@prestashop.adapter.cache.clearer.class_index_cache_clearer'
- '@prestashop.adapter.debug_profiling'
+ - '@prestashop.core.cache.clearer.cache_clearer_chain'
prestashop.adapter.optional_features.configuration:
class: 'PrestaShop\PrestaShop\Adapter\OptionalFeatures\OptionalFeaturesConfiguration'
@@ -215,13 +216,19 @@ services:
arguments:
- '@prestashop.adapter.legacy.configuration'
- prestashop.adapter.webservice.configuration:
- class: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceConfiguration'
+ PrestaShop\PrestaShop\Adapter\Webservice\WebserviceConfiguration:
+ public: false
arguments:
- '@prestashop.adapter.legacy.configuration'
- '@prestashop.adapter.shop.context'
- '@prestashop.adapter.multistore_feature'
+ prestashop.adapter.webservice.configuration:
+ alias: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceConfiguration'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
prestashop.adapter.meta.set_up_urls.configuration:
class: 'PrestaShop\PrestaShop\Adapter\Meta\SetUpUrlsDataConfiguration'
arguments:
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml b/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml
index 5d9063db368f6..dadd6a0777c07 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/data_provider.yml
@@ -34,7 +34,8 @@ services:
prestashop.adapter.data_provider.carrier:
class: PrestaShop\PrestaShop\Adapter\Carrier\CarrierDataProvider
- arguments: [ '@prestashop.adapter.legacy.configuration' ]
+ arguments:
+ - '@prestashop.adapter.legacy.configuration'
prestashop.adapter.data_provider.order_invoice:
class: PrestaShop\PrestaShop\Adapter\Invoice\OrderInvoiceDataProvider
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/email.yml b/src/PrestaShopBundle/Resources/config/services/adapter/email.yml
index 1c8047d27e4d2..74ccc798b9564 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/email.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/email.yml
@@ -8,5 +8,9 @@ services:
- '@prestashop.adapter.legacy.configuration'
- '@translator'
+ PrestaShop\PrestaShop\Core\Email\EmailConfigurationTesterInterface: '@prestashop.adapter.email.email_configuration_tester'
+
prestashop.adapter.email.email_log_eraser:
class: 'PrestaShop\PrestaShop\Adapter\Email\EmailLogEraser'
+
+ PrestaShop\PrestaShop\Core\Email\EmailLogEraserInterface: '@prestashop.adapter.email.email_log_eraser'
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/employee.yml b/src/PrestaShopBundle/Resources/config/services/adapter/employee.yml
index e55569be1136f..04af67c6b99b9 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/employee.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/employee.yml
@@ -30,6 +30,8 @@ services:
- '@prestashop.adapter.data_provider.employee'
- '@prestashop.adapter.employee.data_provider'
+ PrestaShop\PrestaShop\Core\Employee\Access\EmployeeFormAccessCheckerInterface: '@prestashop.adapter.employee.form_access_checker'
+
prestashop.adapter.employee.command_handler.add_employee_handler:
class: 'PrestaShop\PrestaShop\Adapter\Profile\Employee\CommandHandler\AddEmployeeHandler'
autoconfigure: true
@@ -60,11 +62,15 @@ services:
arguments:
- '@prestashop.adapter.legacy.context'
+ PrestaShop\PrestaShop\Core\Employee\NavigationMenuTogglerInterface: '@prestashop.adapter.employee.navigation_menu_toggler'
+
prestashop.adapter.employee.form_language_changer:
class: 'PrestaShop\PrestaShop\Adapter\Employee\FormLanguageChanger'
arguments:
- '@prestashop.adapter.legacy.context'
+ PrestaShop\PrestaShop\Core\Employee\FormLanguageChangerInterface: '@prestashop.adapter.employee.form_language_changer'
+
prestashop.adapter.employee.query_handler.get_employee_email_by_id_handler:
class: PrestaShop\PrestaShop\Adapter\Profile\Employee\QueryHandler\GetEmployeeEmailByIdHandler
autoconfigure: true
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/import.yml b/src/PrestaShopBundle/Resources/config/services/adapter/import.yml
index 939e395169bc0..fb8fcdad1f186 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/import.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/import.yml
@@ -76,6 +76,8 @@ services:
- '@prestashop.adapter.import.handler.category'
- '@prestashop.adapter.import.handler.product'
+ PrestaShop\PrestaShop\Core\Import\Handler\ImportHandlerFinderInterface: '@prestashop.adapter.import.handler_finder'
+
prestashop.adapter.import.data_formatter:
class: 'PrestaShop\PrestaShop\Adapter\Import\ImportDataFormatter'
arguments:
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/module.yml b/src/PrestaShopBundle/Resources/config/services/adapter/module.yml
index 2d329f9fd4173..32fb10c3e9240 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/module.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/module.yml
@@ -15,6 +15,11 @@ services:
autowire: true
public: false
+ PrestaShop\PrestaShop\Adapter\Module\CommandHandler\ResetModuleHandler:
+ autoconfigure: true
+ autowire: true
+ public: false
+
PrestaShop\PrestaShop\Adapter\Module\QueryHandler\GetModuleInfosHandler:
autowire: true
autoconfigure: true
@@ -89,8 +94,15 @@ services:
prestashop.adapter.legacy.module:
class: PrestaShop\PrestaShop\Adapter\Module\Module
- prestashop.adapter.module.repository.module_repository:
- class: 'PrestaShop\PrestaShop\Adapter\Module\Repository\ModuleRepository'
+ PrestaShop\PrestaShop\Adapter\Module\Repository\ModuleRepository:
+ public: false
arguments:
- !php/const _PS_ROOT_DIR_
- !php/const _PS_MODULE_DIR_
+
+ prestashop.adapter.module.repository.module_repository:
+ alias: 'PrestaShop\PrestaShop\Adapter\Module\Repository\ModuleRepository'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+ public: true
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/services.yml b/src/PrestaShopBundle/Resources/config/services/adapter/services.yml
index f55126b46f0bc..89ccd634c625f 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/services.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/services.yml
@@ -15,19 +15,37 @@ services:
prestashop.adapter.mailing_information:
class: 'PrestaShop\PrestaShop\Adapter\Mail\MailingInformation'
- prestashop.adapter.check_requirements:
- class: 'PrestaShop\PrestaShop\Adapter\Requirement\CheckRequirements'
+ PrestaShop\PrestaShop\Adapter\Requirement\CheckRequirements:
+ public: false
arguments: [ '@translator' ]
- prestashop.adapter.system_information:
- class: 'PrestaShop\PrestaShop\Adapter\System\SystemInformation'
+ prestashop.adapter.check_requirements:
+ alias: 'PrestaShop\PrestaShop\Adapter\Requirement\CheckRequirements'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
+ PrestaShop\PrestaShop\Adapter\System\SystemInformation:
+ public: false
arguments:
- '@prestashop.adapter.hosting_information'
- '@prestashop.adapter.mailing_information'
- '@prestashop.adapter.shop_information'
+ prestashop.adapter.system_information:
+ alias: 'PrestaShop\PrestaShop\Adapter\System\SystemInformation'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
+ PrestaShop\PrestaShop\Adapter\Requirement\CheckMissingOrUpdatedFiles:
+ public: false
+
prestashop.adapter.check_missing_files:
- class: 'PrestaShop\PrestaShop\Adapter\Requirement\CheckMissingOrUpdatedFiles'
+ alias: 'PrestaShop\PrestaShop\Adapter\Requirement\CheckMissingOrUpdatedFiles'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
prestashop.adapter.debug_mode:
class: 'PrestaShop\PrestaShop\Adapter\Debug\DebugMode'
diff --git a/src/PrestaShopBundle/Resources/config/services/adapter/webservice.yml b/src/PrestaShopBundle/Resources/config/services/adapter/webservice.yml
index 607730bfa5906..f7bc3c7af30f2 100644
--- a/src/PrestaShopBundle/Resources/config/services/adapter/webservice.yml
+++ b/src/PrestaShopBundle/Resources/config/services/adapter/webservice.yml
@@ -2,14 +2,26 @@ services:
_defaults:
public: true
+ PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyEraser:
+ public: false
+
prestashop.adapter.webservice.webservice_key_eraser:
- class: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyEraser'
+ alias: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyEraser'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
- prestashop.adapter.webservice.webservice_key_status_modifier:
- class: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyStatusModifier'
+ PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyStatusModifier:
+ public: false
arguments:
- '@translator'
+ prestashop.adapter.webservice.webservice_key_status_modifier:
+ alias: 'PrestaShop\PrestaShop\Adapter\Webservice\WebserviceKeyStatusModifier'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
prestashop.adapter.webservice.query_handler.get_webservice_key_for_editing_handler:
class: 'PrestaShop\PrestaShop\Adapter\Webservice\QueryHandler\GetWebserviceKeyForEditingHandler'
autoconfigure: true
diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_provider.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_provider.yml
index a0194a0e31c5d..5c40d5c13271f 100644
--- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_provider.yml
+++ b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_data_provider.yml
@@ -199,10 +199,15 @@ services:
arguments:
- '@prestashop.core.sql_manager.configuration.sql_request_configuration'
+ PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Webservice\WebserviceFormDataProvider:
+ public: false
+ autowire: true
+
prestashop.admin.webservice.form_data_provider:
- class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Webservice\WebserviceFormDataProvider'
- arguments:
- - '@prestashop.adapter.webservice.configuration'
+ alias: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Webservice\WebserviceFormDataProvider'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
prestashop.admin.backup.form_data_provider:
class: 'PrestaShopBundle\Form\Admin\Configure\AdvancedParameters\Backup\BackupDataProvider'
diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/repository.yml b/src/PrestaShopBundle/Resources/config/services/bundle/repository.yml
index 33a679bcfe6ae..ab344c218cc84 100644
--- a/src/PrestaShopBundle/Resources/config/services/bundle/repository.yml
+++ b/src/PrestaShopBundle/Resources/config/services/bundle/repository.yml
@@ -35,12 +35,18 @@ services:
PrestaShop\PrestaShop\Core\Language\LanguageRepositoryInterface: '@prestashop.core.admin.lang.repository'
- prestashop.core.admin.log.repository:
- class: PrestaShopBundle\Entity\Repository\LogRepository
+ PrestaShopBundle\Entity\Repository\LogRepository:
+ public: false
arguments:
- '@doctrine.dbal.default_connection'
- '%database_prefix%'
+ prestashop.core.admin.log.repository:
+ alias: PrestaShopBundle\Entity\Repository\LogRepository
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
prestashop.core.api.stock.repository:
class: PrestaShopBundle\Entity\Repository\StockRepository
arguments:
@@ -97,12 +103,18 @@ services:
- '@doctrine.dbal.default_connection'
- '%database_prefix%'
- prestashop.core.admin.import_match.repository:
- class: PrestaShopBundle\Entity\Repository\ImportMatchRepository
+ PrestaShopBundle\Entity\Repository\ImportMatchRepository:
+ public: false
arguments:
- '@doctrine.dbal.default_connection'
- '%database_prefix%'
+ prestashop.core.admin.import_match.repository:
+ alias: PrestaShopBundle\Entity\Repository\ImportMatchRepository
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
prestashop.bundle.repository.module:
class: PrestaShopBundle\Entity\Repository\ModuleRepository
arguments:
diff --git a/src/PrestaShopBundle/Resources/config/services/core/cldr.yml b/src/PrestaShopBundle/Resources/config/services/core/cldr.yml
index 6bc66ab6e6272..0d2a7cf70d570 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/cldr.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/cldr.yml
@@ -37,11 +37,16 @@ services:
arguments:
- '@prestashop.core.localization.currency.datasource'
- prestashop.core.localization.cldr.locale_repository:
- class: PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository
+ PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository:
arguments:
- '@prestashop.core.localization.cldr.locale_data_source'
+ prestashop.core.localization.cldr.locale_repository:
+ alias: PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleRepository
+ deprecated:
+ package: PrestaShop/PrestaShop
+ version: 9.0
+
prestashop.core.localization.cldr.locale_data_source:
class: PrestaShop\PrestaShop\Core\Localization\CLDR\LocaleDataSource
arguments:
diff --git a/src/PrestaShopBundle/Resources/config/services/core/configuration.yml b/src/PrestaShopBundle/Resources/config/services/core/configuration.yml
index cef236a155330..0c4e109027db0 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/configuration.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/configuration.yml
@@ -13,6 +13,8 @@ services:
class: 'PrestaShop\PrestaShop\Core\Configuration\PhpExtensionChecker'
public: true
+ PrestaShop\PrestaShop\Core\Configuration\PhpExtensionCheckerInterface: '@prestashop.core.configuration.php_extension_checker'
+
prestashop.core.configuration.upload_size_configuration:
class: 'PrestaShop\PrestaShop\Core\Configuration\UploadSizeConfiguration'
arguments:
diff --git a/src/PrestaShopBundle/Resources/config/services/core/currency.yml b/src/PrestaShopBundle/Resources/config/services/core/currency.yml
index 0fa3893be576d..c3321f4766807 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/currency.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/currency.yml
@@ -33,5 +33,10 @@ services:
- '@prestashop.core.currency.exchange_rate.circuit_breaker'
- '@cache.app'
+ PrestaShop\PrestaShop\Core\Localization\Currency\PatternTransformer: ~
+
prestashop.core.localization.currency.pattern_transformer:
- class: PrestaShop\PrestaShop\Core\Localization\Currency\PatternTransformer
+ alias: PrestaShop\PrestaShop\Core\Localization\Currency\PatternTransformer
+ deprecated:
+ package: PrestaShop/PrestaShop
+ version: 9.0
diff --git a/src/PrestaShopBundle/Resources/config/services/core/employee.yml b/src/PrestaShopBundle/Resources/config/services/core/employee.yml
index 5ecfc9ac97fcf..352cf9bcf2076 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/employee.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/employee.yml
@@ -8,6 +8,8 @@ services:
- '@prestashop.adapter.multistore_feature'
- '@prestashop.adapter.shop.context'
+ PrestaShop\PrestaShop\Core\Team\Employee\Configuration\OptionsCheckerInterface: '@prestashop.core.team.employee.configuration.options_checker'
+
prestashop.core.employee.profile_access_checker:
class: 'PrestaShop\PrestaShop\Core\Employee\Access\ProfileAccessChecker'
arguments:
diff --git a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_filter_form_factory.yml b/src/PrestaShopBundle/Resources/config/services/core/grid/grid_filter_form_factory.yml
index 1b09b23d0f4dc..34b6adf6af0be 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/grid/grid_filter_form_factory.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/grid/grid_filter_form_factory.yml
@@ -2,12 +2,18 @@ services:
_defaults:
public: true
- prestashop.core.grid.filter.form_factory:
- class: 'PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactory'
+ PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactory:
+ public: false
arguments:
- '@form.factory'
- '@prestashop.core.hook.dispatcher'
+ prestashop.core.grid.filter.form_factory:
+ alias: 'PrestaShop\PrestaShop\Core\Grid\Filter\GridFilterFormFactory'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
prestashop.core.grid.filter.category_form_factory:
class: 'PrestaShop\PrestaShop\Core\Grid\Filter\CategoryFilterFormFactory'
arguments:
diff --git a/src/PrestaShopBundle/Resources/config/services/core/import.yml b/src/PrestaShopBundle/Resources/config/services/core/import.yml
index 59b49b8e7786e..552587a799215 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/import.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/import.yml
@@ -2,32 +2,59 @@ services:
_defaults:
public: true
- prestashop.core.import.file_uploader:
- class: 'PrestaShop\PrestaShop\Core\Import\File\FileUploader'
+ PrestaShop\PrestaShop\Core\Import\File\FileUploader:
+ public: false
arguments:
- '@translator'
- '@prestashop.core.import.dir'
- prestashop.core.import.file_finder:
- class: 'PrestaShop\PrestaShop\Core\Import\File\FileFinder'
+ prestashop.core.import.file_uploader:
+ alias: 'PrestaShop\PrestaShop\Core\Import\File\FileUploader'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
+ PrestaShop\PrestaShop\Core\Import\File\FileFinder:
+ public: false
arguments:
- '@prestashop.core.import.dir'
- prestashop.core.import.dir:
- class: 'PrestaShop\PrestaShop\Core\Import\ImportDirectory'
+ prestashop.core.import.file_finder:
+ alias: 'PrestaShop\PrestaShop\Core\Import\File\FileFinder'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
+ PrestaShop\PrestaShop\Core\Import\ImportDirectory:
+ public: false
arguments:
- '@prestashop.adapter.legacy.configuration'
- prestashop.core.import.file_removal:
- class: 'PrestaShop\PrestaShop\Core\Import\File\FileRemoval'
+ prestashop.core.import.dir:
+ alias: 'PrestaShop\PrestaShop\Core\Import\ImportDirectory'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
+ PrestaShop\PrestaShop\Core\Import\File\FileRemoval:
+ public: false
arguments:
- '@prestashop.core.import.dir'
- prestashop.core.import.sample.file_provider:
- class: 'PrestaShop\PrestaShop\Core\Import\Sample\SampleFileProvider'
+ prestashop.core.import.file_removal:
+ alias: 'PrestaShop\PrestaShop\Core\Import\File\FileRemoval'
+
+ PrestaShop\PrestaShop\Core\Import\Sample\SampleFileProvider:
+ public: false
arguments:
- '@prestashop.adapter.legacy.configuration'
+ prestashop.core.import.sample.file_provider:
+ alias: 'PrestaShop\PrestaShop\Core\Import\Sample\SampleFileProvider'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
prestashop.core.import.csv_file_reader:
class: 'PrestaShop\PrestaShop\Core\Import\File\CsvFileReader'
arguments:
@@ -42,11 +69,15 @@ services:
arguments:
- '@prestashop.core.import.data_row.presenter'
+ PrestaShop\PrestaShop\Core\Import\File\DataRow\DataRowCollectionPresenterInterface: '@prestashop.core.import.data_row.collection_presenter'
+
prestashop.core.import.factory.data_row.collection_factory:
class: 'PrestaShop\PrestaShop\Core\Import\File\DataRow\Factory\DataRowCollectionFactory'
arguments:
- '@prestashop.core.import.csv_file_reader'
+ PrestaShop\PrestaShop\Core\Import\File\DataRow\Factory\DataRowCollectionFactoryInterface: '@prestashop.core.import.factory.data_row.collection_factory'
+
prestashop.core.import.fields_provider.product:
class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\ProductFieldsProvider'
arguments:
@@ -90,8 +121,8 @@ services:
prestashop.core.import.normalizer.csv_value_separator:
class: 'PrestaShop\PrestaShop\Core\Import\CsvValueSeparatorNormalizer'
- prestashop.core.import.fields_provider_finder:
- class: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\EntityFieldsProviderFinder'
+ PrestaShop\PrestaShop\Core\Import\EntityField\Provider\EntityFieldsProviderFinder:
+ public: false
arguments:
- 0: '@prestashop.core.import.fields_provider.category'
1: '@prestashop.core.import.fields_provider.product'
@@ -103,15 +134,27 @@ services:
7: '@prestashop.core.import.fields_provider.alias'
8: '@prestashop.core.import.fields_provider.store_contact'
+ prestashop.core.import.fields_provider_finder:
+ alias: 'PrestaShop\PrestaShop\Core\Import\EntityField\Provider\EntityFieldsProviderFinder'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
+
prestashop.core.import.config_factory:
class: 'PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigFactory'
+ PrestaShop\PrestaShop\Core\Import\Configuration\ImportConfigFactoryInterface: '@prestashop.core.import.config_factory'
+
prestashop.core.import.runtime_config_factory:
class: 'PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigFactory'
+ PrestaShop\PrestaShop\Core\Import\Configuration\ImportRuntimeConfigFactoryInterface: '@prestashop.core.import.runtime_config_factory'
+
prestashop.core.import.request_validator:
class: 'PrestaShop\PrestaShop\Core\Import\Validator\ImportRequestValidator'
+ PrestaShop\PrestaShop\Core\Import\Validator\ImportRequestValidatorInterface: '@prestashop.core.import.request_validator'
+
prestashop.core.import.access_checker:
class: 'PrestaShop\PrestaShop\Core\Import\Access\ImportAccessChecker'
arguments:
@@ -125,3 +168,5 @@ services:
- '@prestashop.core.import.csv_file_reader'
- '@prestashop.core.import.dir'
- '@prestashop.core.configuration.ini_configuration'
+
+ PrestaShop\PrestaShop\Core\Import\ImporterInterface: '@prestashop.core.import.importer'
diff --git a/src/PrestaShopBundle/Resources/config/services/core/sql_request.yml b/src/PrestaShopBundle/Resources/config/services/core/sql_request.yml
index 85195d74dcd60..cfc94efd53d23 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/sql_request.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/sql_request.yml
@@ -2,10 +2,17 @@ services:
_defaults:
public: true
- prestashop.core.sql_manager.exporter.sql_request_exporter:
- class: 'PrestaShop\PrestaShop\Core\SqlManager\Exporter\SqlRequestExporter'
+ PrestaShop\PrestaShop\Core\SqlManager\Exporter\SqlRequestExporter:
+ public: false
arguments:
- '@prestashop.core.export.file_writer.export_csv_file_writer'
+ - '@prestashop.adapter.legacy.configuration'
+
+ prestashop.core.sql_manager.exporter.sql_request_exporter:
+ alias: 'PrestaShop\PrestaShop\Core\SqlManager\Exporter\SqlRequestExporter'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
prestashop.core.sql_manager.configuration.sql_request_configuration:
class: 'PrestaShop\PrestaShop\Core\SqlManager\Configuration\SqlRequestConfiguration'
diff --git a/src/PrestaShopBundle/Resources/config/services/core/webservice.yml b/src/PrestaShopBundle/Resources/config/services/core/webservice.yml
index b9b929764c495..c4a8e67f8b572 100644
--- a/src/PrestaShopBundle/Resources/config/services/core/webservice.yml
+++ b/src/PrestaShopBundle/Resources/config/services/core/webservice.yml
@@ -1,11 +1,19 @@
services:
_defaults:
- public: true
+ public: false
- prestashop.core.webservice.server_requirements_checker:
- class: 'PrestaShop\PrestaShop\Core\Webservice\ServerRequirementsChecker'
+ PrestaShop\PrestaShop\Core\Webservice\ServerRequirementsChecker:
arguments:
- '@translator'
- '@prestashop.adapter.legacy.configuration'
- '@prestashop.adapter.hosting_information'
- '@prestashop.core.configuration.php_extension_checker'
+
+ PrestaShop\PrestaShop\Core\Webservice\ServerRequirementsCheckerInterface: '@PrestaShop\PrestaShop\Core\Webservice\ServerRequirementsChecker'
+
+ prestashop.core.webservice.server_requirements_checker:
+ public: true
+ alias: 'PrestaShop\PrestaShop\Core\Webservice\ServerRequirementsChecker'
+ deprecated:
+ package: PrestaShop\PrestaShop
+ version: 9.0
diff --git a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig
index 3d424839dbd8f..0a94a5fe775aa 100644
--- a/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig
+++ b/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Manufacturer/logo_image.html.twig
@@ -28,7 +28,6 @@
{{ 'File size'|trans({}, 'Admin.Advparameters.Feature') }} {{ logoImage.size }}