diff --git a/is_themecore/is_themecore.php b/is_themecore/is_themecore.php index 1a65cce..8e89f60 100644 --- a/is_themecore/is_themecore.php +++ b/is_themecore/is_themecore.php @@ -70,12 +70,12 @@ class Is_themecore extends Module $this->displayName = $this->trans( 'Theme core module', [], - 'Modules.isthemecore.Admin' + 'Modules.Isthemecore.Admin' ); $this->description = $this->trans( 'Required for theme to work.', [], - 'Modules.isthemecore.Admin' + 'Modules.Isthemecore.Admin' ); $this->tabs = [ @@ -85,8 +85,9 @@ class Is_themecore extends Module 'route_name' => 'is_themecore_module_settings', 'parent_class_name' => 'CONFIGURE', 'visible' => false, + 'active' => true, 'wording' => 'Theme core module settings', - 'wording_domain' => 'Modules.isthemecore.Admin', + 'wording_domain' => 'Modules.Isthemecore.Admin', ], ]; @@ -183,6 +184,7 @@ class Is_themecore extends Module $router = $container->get('router'); Tools::redirectAdmin($router->generate('is_themecore_module_settings')); + exit; } } diff --git a/is_themecore/src/Controller/Admin/SettingsController.php b/is_themecore/src/Controller/Admin/SettingsController.php index c6f7ca4..2e5f31d 100644 --- a/is_themecore/src/Controller/Admin/SettingsController.php +++ b/is_themecore/src/Controller/Admin/SettingsController.php @@ -7,7 +7,7 @@ namespace Oksydan\Module\IsThemeCore\Controller\Admin; use PrestaShop\PrestaShop\Core\Form\FormHandlerInterface; use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; use PrestaShopBundle\Security\Annotation\AdminSecurity; -use PrestaShopBundle\Security\Annotation\DemoRestricted; +use PrestaShopBundle\Security\Attribute\DemoRestricted; use PrestaShopBundle\Security\Annotation\ModuleActivated; use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -23,7 +23,7 @@ class SettingsController extends FrameworkBundleAdminController { /** * @AdminSecurity( - * "is_granted(['read'], request.get('_legacy_controller'))", + * "is_granted('read', request.get('_legacy_controller'))", * message="You do not have permission to access this." * ) * @@ -53,14 +53,13 @@ class SettingsController extends FrameworkBundleAdminController * redirectRoute="is_themecore_module_settings" * ) * - * @DemoRestricted(redirectRoute="is_themecore_module_settings") - * * @param Request $request * * @return RedirectResponse * * @throws \LogicException */ + #[DemoRestricted(redirectRoute: 'is_themecore_module_settings')] public function processGeneralFormAction(Request $request) { return $this->processForm( @@ -77,14 +76,13 @@ class SettingsController extends FrameworkBundleAdminController * redirectRoute="is_themecore_module_settings" * ) * - * @DemoRestricted(redirectRoute="is_themecore_module_settings") - * * @param Request $request * * @return RedirectResponse * * @throws \LogicException */ + #[DemoRestricted(redirectRoute: 'is_themecore_module_settings')] public function processWebpFormAction(Request $request) { return $this->processForm( @@ -95,14 +93,13 @@ class SettingsController extends FrameworkBundleAdminController } /** - * @DemoRestricted(redirectRoute="is_themecore_module_settings") - * * @param Request $request * * @return RedirectResponse * * @throws \LogicException */ + #[DemoRestricted(redirectRoute: 'is_themecore_module_settings')] public function processWebpEraseImages(Request $request) { $time_start = microtime(true); @@ -110,22 +107,22 @@ class SettingsController extends FrameworkBundleAdminController switch ($request->get('type')) { case 'all': - $eraser->setQuery(_PS_ROOT_DIR_); + $eraser->setQuery(\_PS_ROOT_DIR_); break; case 'product': - $eraser->setQuery(_PS_PROD_IMG_DIR_); + $eraser->setQuery(\_PS_IMG_DIR_ . 'p/'); break; case 'module': - $eraser->setQuery(_PS_MODULE_DIR_); + $eraser->setQuery(\_PS_MODULE_DIR_); break; case 'cms': - $eraser->setQuery(_PS_IMG_DIR_ . 'cms/'); + $eraser->setQuery(\_PS_IMG_DIR_ . 'cms/'); break; case 'themes': - $eraser->setQuery(_PS_ROOT_DIR_ . '/themes/'); + $eraser->setQuery(\_PS_ROOT_DIR_ . '/themes/'); break; default: - $eraser->setQuery(_PS_ROOT_DIR_); + $eraser->setQuery(\_PS_ROOT_DIR_); break; } @@ -134,7 +131,7 @@ class SettingsController extends FrameworkBundleAdminController $time_end = microtime(true); $execution_time = round($time_end - $time_start, 2); - $this->addFlash('success', $this->trans('%1$s - webp images has been erased successfully in %2$ss', 'Modules.isthemecore.Admin', [$eraser->getFilesCount(), $execution_time])); + $this->addFlash('success', $this->trans('%1$s - webp images has been erased successfully in %2$ss', 'Modules.Isthemecore.Admin', [$eraser->getFilesCount(), $execution_time])); return $this->redirectToRoute('is_themecore_module_settings'); } diff --git a/is_themecore/src/Form/Settings/GeneralType.php b/is_themecore/src/Form/Settings/GeneralType.php index dc88221..77165c9 100644 --- a/is_themecore/src/Form/Settings/GeneralType.php +++ b/is_themecore/src/Form/Settings/GeneralType.php @@ -9,7 +9,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\FormBuilderInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; class GeneralType extends TranslatorAwareType { @@ -52,7 +52,7 @@ class GeneralType extends TranslatorAwareType ChoiceType::class, [ 'choices' => $this->displayListChoices, - 'label' => $this->trans('Default list display', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Default list display', 'Modules.Isthemecore.Admin'), 'multistore_configuration_key' => GeneralConfiguration::THEMECORE_DISPLAY_LIST, ] ) @@ -60,8 +60,8 @@ class GeneralType extends TranslatorAwareType SwitchType::class, [ 'required' => false, - 'label' => $this->trans('Early hints (HTTP 103) enabled', 'Modules.isthemecore.Admin'), - 'help' => $this->trans('Cloudflare CDN, Early hints option have to enabled. More information', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Early hints (HTTP 103) enabled', 'Modules.Isthemecore.Admin'), + 'help' => $this->trans('Cloudflare CDN, Early hints option have to enabled. More information', 'Modules.Isthemecore.Admin'), 'multistore_configuration_key' => GeneralConfiguration::THEMECORE_EARLY_HINTS, ] ) @@ -69,7 +69,7 @@ class GeneralType extends TranslatorAwareType SwitchType::class, [ 'required' => false, - 'label' => $this->trans('Preload css enabled, only working with CCC for css option enabled', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Preload css enabled, only working with CCC for css option enabled', 'Modules.Isthemecore.Admin'), 'multistore_configuration_key' => GeneralConfiguration::THEMECORE_PRELOAD_CSS, ] ) @@ -77,8 +77,8 @@ class GeneralType extends TranslatorAwareType SwitchType::class, [ 'required' => false, - 'label' => $this->trans('Load partytown script', 'Modules.isthemecore.Admin'), - 'help' => $this->trans('Be aware that partytown is still beta. Make sure that everything is working as expected before pushing it to your production store.', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Load partytown script', 'Modules.Isthemecore.Admin'), + 'help' => $this->trans('Be aware that partytown is still beta. Make sure that everything is working as expected before pushing it to your production store.', 'Modules.Isthemecore.Admin'), 'multistore_configuration_key' => GeneralConfiguration::THEMECORE_LOAD_PARTY_TOWN, ] ) @@ -86,7 +86,7 @@ class GeneralType extends TranslatorAwareType SwitchType::class, [ 'required' => false, - 'label' => $this->trans('Enable debug mode for partytown', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Enable debug mode for partytown', 'Modules.Isthemecore.Admin'), 'multistore_configuration_key' => GeneralConfiguration::THEMECORE_DEBUG_PARTY_TOWN, ] ); diff --git a/is_themecore/src/Form/Settings/WebpType.php b/is_themecore/src/Form/Settings/WebpType.php index 7d50ad4..8409d6f 100644 --- a/is_themecore/src/Form/Settings/WebpType.php +++ b/is_themecore/src/Form/Settings/WebpType.php @@ -12,7 +12,7 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Routing\RouterInterface; -use Symfony\Component\Translation\TranslatorInterface; +use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Component\Validator\Constraints\NotBlank; use Symfony\Component\Validator\Constraints\Range; @@ -79,7 +79,7 @@ class WebpType extends TranslatorAwareType if ($webpDisabled) { $extraAttributes = [ - 'alert_message' => $this->trans('Webp converters not available contact your admin or hosting provider.', 'Modules.isthemecore.Admin'), + 'alert_message' => $this->trans('Webp converters not available contact your admin or hosting provider.', 'Modules.Isthemecore.Admin'), 'alert_type' => 'danger', 'alert_position' => 'append', ]; @@ -91,7 +91,7 @@ class WebpType extends TranslatorAwareType array_merge( [ 'required' => false, - 'label' => $this->trans('Enable WEBP', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Enable WEBP', 'Modules.Isthemecore.Admin'), 'disabled' => $webpDisabled, ], $extraAttributes @@ -101,7 +101,7 @@ class WebpType extends TranslatorAwareType SwitchType::class, [ 'required' => false, - 'label' => $this->trans('Enable better RGB->YUV color conversion', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Enable better RGB->YUV color conversion', 'Modules.Isthemecore.Admin'), 'disabled' => $webpDisabled, ] ) @@ -109,8 +109,8 @@ class WebpType extends TranslatorAwareType TextType::class, [ 'required' => false, - 'label' => $this->trans('Webp quality', 'Modules.isthemecore.Admin'), - 'help' => $this->trans('Range 1-100', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Webp quality', 'Modules.Isthemecore.Admin'), + 'help' => $this->trans('Range 1-100', 'Modules.Isthemecore.Admin'), 'disabled' => $webpDisabled, 'constraints' => [ $this->getRangeConstraint(1, 100), @@ -122,7 +122,7 @@ class WebpType extends TranslatorAwareType ChoiceType::class, [ 'choices' => $this->convertersList, - 'label' => $this->trans('Webp converter options', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Webp converter options', 'Modules.Isthemecore.Admin'), 'disabled' => $webpDisabled, 'expanded' => true, 'multiple' => false, @@ -130,12 +130,12 @@ class WebpType extends TranslatorAwareType return ['disabled' => $this->convertersListFull[$choice]['disabled']]; }, 'choice_label' => function ($choice) { - return $this->convertersListFull[$choice]['label'] . ($this->convertersListFull[$choice]['disabled'] ? '' . $this->trans('not available', 'Modules.isthemecore.Admin') . '' : ''); + return $this->convertersListFull[$choice]['label'] . ($this->convertersListFull[$choice]['disabled'] ? '' . $this->trans('not available', 'Modules.Isthemecore.Admin') . '' : ''); }, ] ) ->add('erase_all_webp', IconButtonType::class, [ - 'label' => $this->trans('Erase all webp images', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Erase all webp images', 'Modules.Isthemecore.Admin'), 'type' => 'link', 'icon' => 'delete', 'attr' => [ @@ -149,7 +149,7 @@ class WebpType extends TranslatorAwareType ], ]) ->add('erase_product_webp', IconButtonType::class, [ - 'label' => $this->trans('Erase all product webp images', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Erase all product webp images', 'Modules.Isthemecore.Admin'), 'type' => 'link', 'icon' => 'delete', 'attr' => [ @@ -163,7 +163,7 @@ class WebpType extends TranslatorAwareType ], ]) ->add('erase_modules_webp', IconButtonType::class, [ - 'label' => $this->trans('Erase all modules webp images', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Erase all modules webp images', 'Modules.Isthemecore.Admin'), 'type' => 'link', 'icon' => 'delete', 'attr' => [ @@ -177,7 +177,7 @@ class WebpType extends TranslatorAwareType ], ]) ->add('erase_cms_webp', IconButtonType::class, [ - 'label' => $this->trans('Erase all CMS webp images', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Erase all CMS webp images', 'Modules.Isthemecore.Admin'), 'type' => 'link', 'icon' => 'delete', 'attr' => [ @@ -191,7 +191,7 @@ class WebpType extends TranslatorAwareType ], ]) ->add('erase_themes_webp', IconButtonType::class, [ - 'label' => $this->trans('Erase all themes webp images', 'Modules.isthemecore.Admin'), + 'label' => $this->trans('Erase all themes webp images', 'Modules.Isthemecore.Admin'), 'type' => 'link', 'icon' => 'delete', 'attr' => [ @@ -222,7 +222,7 @@ class WebpType extends TranslatorAwareType private function getNotBlankConstraint() { return new NotBlank([ - 'message' => $this->trans('This field cannot be empty.', 'Modules.isthemecore.Admin'), + 'message' => $this->trans('This field cannot be empty.', 'Modules.Isthemecore.Admin'), ]); } @@ -236,7 +236,7 @@ class WebpType extends TranslatorAwareType 'max' => $max, 'invalidMessage' => $this->trans( 'This field value have to be between %min% and %max%.', - 'Modules.isthemecore.Admin', + 'Modules.Isthemecore.Admin', [ '%min%' => $min, '%max%' => $max, diff --git a/is_themecore/views/templates/back/components/layouts/settings.html.twig b/is_themecore/views/templates/back/components/layouts/settings.html.twig index de93c72..e85363f 100644 --- a/is_themecore/views/templates/back/components/layouts/settings.html.twig +++ b/is_themecore/views/templates/back/components/layouts/settings.html.twig @@ -8,7 +8,7 @@ 'form': general_form, 'form_id': 'settings_general_form', 'form_action': path('is_themecore_module_settings_general_save'), - 'card_header': 'General' | trans({}, 'Modules.isthemecore.Admin'), + 'card_header': 'General' | trans({}, 'Modules.Isthemecore.Admin'), 'cancel_path': 'is_themecore_module_settings' } %} @@ -18,7 +18,7 @@ 'form': webp_form, 'form_id': 'settings_webp_form', 'form_action': path('is_themecore_module_settings_webp_save'), - 'card_header': 'Webp' | trans({}, 'Modules.isthemecore.Admin'), + 'card_header': 'Webp' | trans({}, 'Modules.Isthemecore.Admin'), 'icon_header': 'image', 'cancel_path': 'is_themecore_module_settings' } %}