diff --git a/.gitignore b/.gitignore index f486a1f..0b67069 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ /node_modules/ /composer.lock +/.idea/ + /etc/build/* !/etc/build/.gitignore diff --git a/composer.json b/composer.json index a2687ce..05ed907 100644 --- a/composer.json +++ b/composer.json @@ -8,13 +8,22 @@ ], "license": "MIT", "require": { - "php": "^7.4 || ^8.1", - "sherlockode/advanced-content-bundle": "^0.9.8", - "sylius/sylius": "^1.10" + "php": "^8.2", + "sherlockode/advanced-content-bundle": "^0.10", + "sylius/sylius": "^2.0", + "symfony/framework-bundle": "^7.4", + "symfony/form": "^7.4", + "symfony/twig-bundle": "^7.4", + "twig/twig": "^3.0" }, "config": { "sort-packages": true }, + "extra": { + "branch-alias": { + "dev-sylius-2": "1.0.x-dev" + } + }, "autoload": { "psr-4": { "Sherlockode\\SyliusAdvancedContentPlugin\\": "src/" diff --git a/src/Command/ScopeInitCommand.php b/src/Command/ScopeInitCommand.php index 9fe053f..8d89e6a 100644 --- a/src/Command/ScopeInitCommand.php +++ b/src/Command/ScopeInitCommand.php @@ -1,5 +1,7 @@ configurationManager = $configurationManager; - $this->translator = $translator; - $this->scopeInitializer = $scopeInitializer; + parent::__construct(); } - protected function configure() + protected function configure(): void { $this ->setName('sherlockode:sylius-acb:init-scope') @@ -53,46 +30,31 @@ protected function configure() ; } - /** - * @param InputInterface $input - * @param OutputInterface $output - * - * @return int|void - */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $io = new SymfonyStyle($input, $output); if (!$this->configurationManager->isScopesEnabled()) { $io->info($this->translator->trans('sherlockode_sylius_acb.scopes.disabled')); - if (defined(sprintf('%s::SUCCESS', get_class($this)))) { - return self::SUCCESS; - } - return; + return self::SUCCESS; } + if (!$this->scopeInitializer->hasMissingScopes()) { $io->info($this->translator->trans('sherlockode_sylius_acb.scopes.up_to_date')); - if (defined(sprintf('%s::SUCCESS', get_class($this)))) { - return self::SUCCESS; - } - return; + return self::SUCCESS; } try { $this->scopeInitializer->init(); $io->success($this->translator->trans('sherlockode_sylius_acb.scopes.init_success')); - if (defined(sprintf('%s::SUCCESS', get_class($this)))) { - return self::SUCCESS; - } - return; + + return self::SUCCESS; } catch (\Exception $e) { $io->error($e->getMessage()); - if (defined(sprintf('%s::FAILURE', get_class($this)))) { - return self::FAILURE; - } + return self::FAILURE; } } } diff --git a/src/Controller/PreviewController.php b/src/Controller/PreviewController.php index 4f41e89..6f3f376 100644 --- a/src/Controller/PreviewController.php +++ b/src/Controller/PreviewController.php @@ -1,11 +1,13 @@ channelLocaleScopeHandler = $channelLocaleScopeHandler; - $this->pageRepository = $pageRepository; - $this->viewHandler = $viewHandler; } - /** - * @param Request $request - * @param string $pageIdentifier - * - * @return Response - * - * @throws \Exception - */ - public function previewAction( - Request $request, - string $pageIdentifier - ): Response { + public function previewAction(Request $request, string $pageIdentifier): Response + { $channelCode = $request->query->get('_channel_code'); $localeCode = $request->query->get('_locale'); @@ -67,7 +36,7 @@ public function previewAction( throw new NotFoundHttpException(sprintf( 'Scope for channel "%s" and locale "%s" does not exists', $channelCode, - $localeCode + $localeCode, )); } @@ -77,7 +46,7 @@ public function previewAction( throw new NotFoundHttpException(sprintf( 'Page with scope for channel "%s" and locale "%s" does not exists', $channelCode, - $localeCode + $localeCode, )); } @@ -86,7 +55,7 @@ public function previewAction( if (!$template) { throw new \Exception(sprintf( 'Cannot find any template for the page "%s" preview', - $page->getPageIdentifier() + $page->getPageIdentifier(), )); } diff --git a/src/Controller/ScopeController.php b/src/Controller/ScopeController.php index 1c685cb..9d1fb83 100644 --- a/src/Controller/ScopeController.php +++ b/src/Controller/ScopeController.php @@ -1,50 +1,25 @@ configurationManager = $configurationManager; - $this->scopeInitializer = $scopeInitializer; - $this->translator = $translator; } - /** - * @return Response - */ - public function updateScopesAction() + public function updateScopesAction(): Response { if (!$this->configurationManager->isScopesEnabled()) { $this->addFlash('error', $this->translator->trans('sherlockode_sylius_acb.scopes.disabled')); diff --git a/src/DependencyInjection/Compiler/SyliusClassMappingCompilerPass.php b/src/DependencyInjection/Compiler/SyliusClassMappingCompilerPass.php index 50a943b..c63ef75 100644 --- a/src/DependencyInjection/Compiler/SyliusClassMappingCompilerPass.php +++ b/src/DependencyInjection/Compiler/SyliusClassMappingCompilerPass.php @@ -1,5 +1,7 @@ requestStack = $requestStack; - $this->translator = $translator; - $this->scopeInitializer = $scopeInitializer; - $this->configurationManager = $configurationManager; } - /** - * @param GenericEvent $event - */ public function checkScopeInitialization(GenericEvent $event): void { if (!$this->configurationManager->isScopesEnabled()) { return; } + if (!$this->scopeInitializer->hasMissingScopes()) { return; } diff --git a/src/EventListener/AdminVersionListener.php b/src/EventListener/AdminVersionListener.php index 12d8fb4..3592c96 100644 --- a/src/EventListener/AdminVersionListener.php +++ b/src/EventListener/AdminVersionListener.php @@ -1,5 +1,7 @@ requestStack = $requestStack; - $this->translator = $translator; - $this->configurationManager = $configurationManager; - $this->em = $em; } public function editContentVersionMessage(): void @@ -58,9 +30,6 @@ public function editPageVersionMessage(): void $this->addVersionMessage('page_version'); } - /** - * @param string $entityClass - */ private function addVersionMessage(string $entityClass): void { $request = $this->requestStack->getMainRequest(); @@ -73,7 +42,7 @@ private function addVersionMessage(string $entityClass): void return; } - /** @var VersionInterface $version */ + /** @var VersionInterface|null $version */ $version = $this->em->getRepository($this->configurationManager->getEntityClass($entityClass))->find($versionId); if ($version === null) { return; @@ -82,7 +51,7 @@ private function addVersionMessage(string $entityClass): void $formatter = \IntlDateFormatter::create( $request->getLocale(), \IntlDateFormatter::MEDIUM, - \IntlDateFormatter::MEDIUM + \IntlDateFormatter::MEDIUM, ); $this->requestStack->getSession()->getFlashBag() diff --git a/src/EventListener/ChannelListener.php b/src/EventListener/ChannelListener.php index 63e9129..66c1ca5 100644 --- a/src/EventListener/ChannelListener.php +++ b/src/EventListener/ChannelListener.php @@ -1,5 +1,7 @@ join('content.scopes', 'scope') ->andWhere('scope.channel = :channel') ->andWhere('scope.locale = :locale') - ->setParameters([ - 'channel' => $scope->getChannel(), - 'locale' => $scope->getLocale(), - ]); + ->setParameter('channel', $scope->getChannel()) + ->setParameter('locale', $scope->getLocale()); } return $qb; diff --git a/src/Repository/PageRepository.php b/src/Repository/PageRepository.php index d16c4a7..ccb7fc5 100644 --- a/src/Repository/PageRepository.php +++ b/src/Repository/PageRepository.php @@ -1,5 +1,7 @@ join('page.scopes', 'scope') ->andWhere('scope.channel = :channel') ->andWhere('scope.locale = :locale') - ->setParameters([ - 'channel' => $scope->getChannel(), - 'locale' => $scope->getLocale(), - ]); + ->setParameter('channel', $scope->getChannel()) + ->setParameter('locale', $scope->getLocale()); } return $qb; diff --git a/src/Resources/config/admin_routing.yaml b/src/Resources/config/admin_routing.yaml index b1771f3..0dc9481 100644 --- a/src/Resources/config/admin_routing.yaml +++ b/src/Resources/config/admin_routing.yaml @@ -2,10 +2,12 @@ sherlockode_sylius_acb_admin_page: resource: | alias: sherlockode_sylius_acb.page section: admin - templates: '@SyliusAdmin\\Crud' + templates: "@SyliusAdmin\\shared\\crud" except: ['show'] redirect: update grid: sherlockode_sylius_acb_admin_page + form: + type: Sherlockode\AdvancedContentBundle\Form\Type\PageType vars: index: icon: 'sticky note' @@ -18,10 +20,12 @@ sherlockode_sylius_acb_admin_content: resource: | alias: sherlockode_sylius_acb.content section: admin - templates: '@SyliusAdmin\\Crud' + templates: "@SyliusAdmin\\shared\\crud" except: ['show'] redirect: update grid: sherlockode_sylius_acb_admin_content + form: + type: Sherlockode\AdvancedContentBundle\Form\Type\ContentType vars: index: icon: 'sticky note outline' diff --git a/src/Resources/config/commands.xml b/src/Resources/config/commands.xml new file mode 100644 index 0000000..429b488 --- /dev/null +++ b/src/Resources/config/commands.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/src/Resources/config/config.yaml b/src/Resources/config/config.yaml index a69ed55..18dbeae 100644 --- a/src/Resources/config/config.yaml +++ b/src/Resources/config/config.yaml @@ -2,4 +2,5 @@ imports: - { resource: "sylius_grid.yaml" } - { resource: "sylius_resource.yaml" } - { resource: "services.yaml" } + - { resource: "commands.xml" } - { resource: "events.yaml" } diff --git a/src/Resources/config/doctrine/Page.orm.xml b/src/Resources/config/doctrine/Page.orm.xml index d6b76e8..c59abca 100644 --- a/src/Resources/config/doctrine/Page.orm.xml +++ b/src/Resources/config/doctrine/Page.orm.xml @@ -13,6 +13,19 @@ + + + + + + + + + + + + + diff --git a/src/Resources/config/events.yaml b/src/Resources/config/events.yaml index 91e8db7..75d754c 100644 --- a/src/Resources/config/events.yaml +++ b/src/Resources/config/events.yaml @@ -1,22 +1,3 @@ -sylius_ui: - events: - sherlockode_sylius_acb.admin.content.create.stylesheets: - blocks: - sylius_acb: - template: "@SherlockodeSyliusAdvancedContentPlugin/admin/stylesheets.html.twig" - sherlockode_sylius_acb.admin.content.update.stylesheets: - blocks: - sylius_acb: - template: "@SherlockodeSyliusAdvancedContentPlugin/admin/stylesheets.html.twig" - sherlockode_sylius_acb.admin.page.create.stylesheets: - blocks: - sylius_acb: - template: "@SherlockodeSyliusAdvancedContentPlugin/admin/stylesheets.html.twig" - sherlockode_sylius_acb.admin.page.update.stylesheets: - blocks: - sylius_acb: - template: "@SherlockodeSyliusAdvancedContentPlugin/admin/stylesheets.html.twig" - services: sherlockode_sylius_acb.listener.grid: class: Sherlockode\SyliusAdvancedContentPlugin\EventListener\AdminGridListener diff --git a/src/Resources/config/services.yaml b/src/Resources/config/services.yaml index affa9fc..77dc20b 100644 --- a/src/Resources/config/services.yaml +++ b/src/Resources/config/services.yaml @@ -22,14 +22,6 @@ services: arguments: - '@doctrine.orm.entity_manager' - '@sherlockode_advanced_content.configuration_manager' - sherlockode_sylius_acb.scope_init_command: - class: Sherlockode\SyliusAdvancedContentPlugin\Command\ScopeInitCommand - arguments: - - '@sherlockode_advanced_content.configuration_manager' - - '@translator' - - '@sherlockode_sylius_acb.scope_initializer' - tags: - - { name: console.command } sherlockode_sylius_acb.controller.preview: class: Sherlockode\SyliusAdvancedContentPlugin\Controller\PreviewController public: true diff --git a/src/Resources/config/sylius_resource.yaml b/src/Resources/config/sylius_resource.yaml index 46274b8..3c59d02 100644 --- a/src/Resources/config/sylius_resource.yaml +++ b/src/Resources/config/sylius_resource.yaml @@ -1,45 +1,36 @@ sylius_resource: resources: sherlockode_sylius_acb.content: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\Content interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\ContentInterface - form: Sherlockode\AdvancedContentBundle\Form\Type\ContentType + repository: Sherlockode\SyliusAdvancedContentPlugin\Repository\ContentRepository sherlockode_sylius_acb.content_version: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\ContentVersion interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\ContentVersionInterface sherlockode_sylius_acb.page: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\Page - form: Sherlockode\AdvancedContentBundle\Form\Type\PageType interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageInterface repository: Sherlockode\SyliusAdvancedContentPlugin\Repository\PageRepository sherlockode_sylius_acb.page_meta: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageMeta interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageMetaInterface sherlockode_sylius_acb.page_meta_version: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageMetaVersion interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageMetaVersionInterface sherlockode_sylius_acb.page_type: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageType interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageTypeInterface sherlockode_sylius_acb.page_version: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageVersion interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\PageVersionInterface sherlockode_sylius_acb.scope: - driver: doctrine/orm classes: model: Sherlockode\SyliusAdvancedContentPlugin\Entity\Scope interface: Sherlockode\SyliusAdvancedContentPlugin\Entity\ScopeInterface diff --git a/src/Resources/js/AdvancedContentBundle/acb-notification.js b/src/Resources/js/AdvancedContentBundle/acb-notification.js index 7bf2418..d0af555 100644 --- a/src/Resources/js/AdvancedContentBundle/acb-notification.js +++ b/src/Resources/js/AdvancedContentBundle/acb-notification.js @@ -1,20 +1,38 @@ -import $ from 'jquery'; -import 'semantic-ui-css/components/modal'; +import Modal from 'bootstrap/js/dist/modal'; let notifAlert = function (message) { - alert(message); + window.alert(message); }; let notifConfirm = function (message, callback) { - $('#confirmation-modal').find('.content p').html(message); - $('#confirmation-button') - .off('click') - .on('click', (event) => { - callback(); - }) - ; - - $('#confirmation-modal').modal('show'); + const modalElement = document.getElementById('confirmation-modal'); + + if (modalElement === null) { + if (window.confirm(message)) { + callback(); + } + + return; + } + + const body = modalElement.querySelector('.modal-body'); + if (body !== null) { + body.innerHTML = message; + } + + const modal = Modal.getOrCreateInstance(modalElement); + const confirmButton = modalElement.querySelector('#confirmation-button'); + + if (confirmButton !== null) { + const freshButton = confirmButton.cloneNode(true); + confirmButton.replaceWith(freshButton); + freshButton.addEventListener('click', () => { + modal.hide(); + callback(); + }, { once: true }); + } + + modal.show(); }; export {notifAlert, notifConfirm}; diff --git a/src/Resources/views/AdvancedContentBundle/Common/Macros/classes.html.twig b/src/Resources/views/AdvancedContentBundle/Common/Macros/classes.html.twig index 16e8d0e..fe01594 100644 --- a/src/Resources/views/AdvancedContentBundle/Common/Macros/classes.html.twig +++ b/src/Resources/views/AdvancedContentBundle/Common/Macros/classes.html.twig @@ -1,16 +1,16 @@ {%- macro table() -%} - ui celled table + table table-bordered {%- endmacro -%} {%- macro button() -%} - ui button + btn btn-secondary {%- endmacro -%} {%- macro buttonPrimary() -%} - ui button primary + btn btn-primary {%- endmacro -%} {%- macro buttonSuccess() -%} - ui button primary + btn btn-success {%- endmacro -%} {%- macro buttonIcon() -%} - ui button icon basic + btn btn-icon {%- endmacro -%} diff --git a/src/Resources/views/AdvancedContentBundle/Common/Macros/collapse.html.twig b/src/Resources/views/AdvancedContentBundle/Common/Macros/collapse.html.twig index ec81042..2989119 100644 --- a/src/Resources/views/AdvancedContentBundle/Common/Macros/collapse.html.twig +++ b/src/Resources/views/AdvancedContentBundle/Common/Macros/collapse.html.twig @@ -1,6 +1,6 @@ {% macro buildAccordion(data) %} {% for item in data %} -
+
{{ item.title|raw }} {{ item.content|raw }} diff --git a/src/Resources/views/AdvancedContentBundle/Common/Macros/tabs.html.twig b/src/Resources/views/AdvancedContentBundle/Common/Macros/tabs.html.twig index deec9a1..5142715 100644 --- a/src/Resources/views/AdvancedContentBundle/Common/Macros/tabs.html.twig +++ b/src/Resources/views/AdvancedContentBundle/Common/Macros/tabs.html.twig @@ -1,31 +1,35 @@ {% macro buildTabs(tabsData, extraClass) %} -