-
Notifications
You must be signed in to change notification settings - Fork 31
Feed the Symfony dashboard's Zone Two hook with product tables, add a settings page #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nicosomb
wants to merge
6
commits into
dev
Choose a base branch
from
feature/41971-zone-two-poc
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
813612f
Feed the Symfony dashboard's Zone Two hook with product tables, add a…
nicosomb d480cb0
Mark as configurable in config.xml, remove a duplicate query in getTa…
nicosomb c1e0ba4
Reset phpVersion in PHPStan config to avoid crashing on CI's PHP 8.5 …
nicosomb f18a1b3
Use the Card Twig component instead of the card-header partial
nicosomb 73c1125
Bump to 3.0.0, replace @DemoRestricted with a manual demo-mode check
nicosomb 7379aa6
Rename the upgrade script to 3.0.0
nicosomb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
| /** | ||
| * Copyright since 2007 PrestaShop SA and Contributors | ||
| * PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
| * | ||
| * NOTICE OF LICENSE | ||
| * | ||
| * This source file is subject to the Academic Free License 3.0 (AFL-3.0) | ||
| * that is bundled with this package in the file LICENSE.md. | ||
| * It is also available through the world-wide-web at this URL: | ||
| * https://opensource.org/licenses/AFL-3.0 | ||
| * If you did not receive a copy of the license and are unable to | ||
| * obtain it through the world-wide-web, please send an email | ||
| * to license@prestashop.com so we can send you a copy immediately. | ||
| * | ||
| * DISCLAIMER | ||
| * | ||
| * Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
| * versions in the future. If you wish to customize PrestaShop for your | ||
| * needs please refer to https://devdocs.prestashop.com/ for more information. | ||
| * | ||
| * @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
| * @copyright Since 2007 PrestaShop SA and Contributors | ||
| * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) | ||
| */ | ||
| header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
| header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
|
|
||
| header('Cache-Control: no-store, no-cache, must-revalidate'); | ||
| header('Cache-Control: post-check=0, pre-check=0', false); | ||
| header('Pragma: no-cache'); | ||
|
|
||
| header('Location: ../'); | ||
| exit; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| dashproducts_configuration: | ||
| path: /dashproducts/configuration | ||
| methods: [GET, POST] | ||
| defaults: | ||
| _controller: PrestaShop\Module\DashProducts\Controller\ConfigurationController::indexAction | ||
| _legacy_controller: AdminDashproductsConfiguration | ||
| _legacy_link: AdminDashproductsConfiguration |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| services: | ||
| PrestaShop\Module\DashProducts\Controller\ConfigurationController: | ||
| public: true | ||
| autowire: true | ||
| autoconfigure: true | ||
|
|
||
| PrestaShop\Module\DashProducts\Type\ConfigurationType: | ||
| autowire: true | ||
| autoconfigure: true | ||
| tags: ['form.type'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| <?php | ||
| /** | ||
| * Copyright since 2007 PrestaShop SA and Contributors | ||
| * PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
| * | ||
| * This source file is subject to the Academic Free License 3.0 (AFL-3.0) | ||
| * that is bundled with this package in the file LICENSE.md. | ||
| * It is also available through the world-wide-web at this URL: | ||
| * https://opensource.org/licenses/AFL-3.0 | ||
| * | ||
| * @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
| * @copyright Since 2007 PrestaShop SA and Contributors | ||
| * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) | ||
| */ | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace PrestaShop\Module\DashProducts\Controller; | ||
|
|
||
| use Configuration; | ||
| use PrestaShop\Module\DashProducts\Type\ConfigurationType; | ||
| // FrameworkBundleAdminController is deprecated since 9.0 in favor of PrestaShopAdminController, | ||
| // which doesn't exist on PS 8.2 — kept for the module's declared 8.2+ compatibility. | ||
| use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; | ||
| use PrestaShopBundle\Security\Annotation\AdminSecurity; | ||
| use Symfony\Component\HttpFoundation\Request; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| class ConfigurationController extends FrameworkBundleAdminController | ||
| { | ||
| private const FIELDS = [ | ||
| 'DASHPRODUCT_NBR_SHOW_LAST_ORDER', | ||
| 'DASHPRODUCT_NBR_SHOW_BEST_SELLER', | ||
| 'DASHPRODUCT_NBR_SHOW_MOST_VIEWED', | ||
| 'DASHPRODUCT_NBR_SHOW_TOP_SEARCH', | ||
| ]; | ||
|
|
||
| /** | ||
| * @AdminSecurity("is_granted('read', request.get('_legacy_controller'))") | ||
| */ | ||
| public function indexAction(Request $request): Response | ||
|
mattgoud marked this conversation as resolved.
|
||
| { | ||
| $data = []; | ||
| foreach (self::FIELDS as $field) { | ||
| $data[$field] = (int) Configuration::get($field); | ||
| } | ||
|
|
||
| $form = $this->createForm(ConfigurationType::class, $data); | ||
| $form->handleRequest($request); | ||
|
|
||
| if ($form->isSubmitted() && $form->isValid()) { | ||
| $this->denyAccessUnlessGranted('update', $request->attributes->get('_legacy_controller')); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not to handle in @adminsecurity ? |
||
|
|
||
| // No @DemoRestricted attribute here: its listener only recognizes the PHP 8 | ||
| // attribute form (PrestaShopBundle\Security\Attribute\DemoRestricted), which | ||
| // doesn't exist on PS 8.2 — this module's declared minimum version. | ||
| if ($this->isDemoModeEnabled()) { | ||
| $this->addFlash('error', $this->trans('This functionality has been disabled.', 'Admin.Notifications.Error')); | ||
|
|
||
| return $this->redirectToRoute('dashproducts_configuration'); | ||
| } | ||
|
|
||
| foreach ($form->getData() as $field => $value) { | ||
| Configuration::updateValue($field, (int) $value); | ||
| } | ||
| $this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success')); | ||
|
|
||
| return $this->redirectToRoute('dashproducts_configuration'); | ||
| } | ||
|
|
||
| return $this->render('@Modules/dashproducts/views/templates/admin/configuration.html.twig', [ | ||
| 'configurationForm' => $form->createView(), | ||
| 'enableSidebar' => true, | ||
| 'help_link' => $this->generateSidebarLink('AdminDashproductsConfiguration'), | ||
| ]); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| <?php | ||
| /** | ||
| * Copyright since 2007 PrestaShop SA and Contributors | ||
| * PrestaShop is an International Registered Trademark & Property of PrestaShop SA | ||
| * | ||
| * NOTICE OF LICENSE | ||
| * | ||
| * This source file is subject to the Academic Free License 3.0 (AFL-3.0) | ||
| * that is bundled with this package in the file LICENSE.md. | ||
| * It is also available through the world-wide-web at this URL: | ||
| * https://opensource.org/licenses/AFL-3.0 | ||
| * If you did not receive a copy of the license and are unable to | ||
| * obtain it through the world-wide-web, please send an email | ||
| * to license@prestashop.com so we can send you a copy immediately. | ||
| * | ||
| * DISCLAIMER | ||
| * | ||
| * Do not edit or add to this file if you wish to upgrade PrestaShop to newer | ||
| * versions in the future. If you wish to customize PrestaShop for your | ||
| * needs please refer to https://devdocs.prestashop.com/ for more information. | ||
| * | ||
| * @author PrestaShop SA and Contributors <contact@prestashop.com> | ||
| * @copyright Since 2007 PrestaShop SA and Contributors | ||
| * @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0) | ||
| */ | ||
| header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | ||
| header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); | ||
|
|
||
| header('Cache-Control: no-store, no-cache, must-revalidate'); | ||
| header('Cache-Control: post-check=0, pre-check=0', false); | ||
| header('Pragma: no-cache'); | ||
|
|
||
| header('Location: ../'); | ||
| exit; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.