Skip to content

Commit 9bf37ec

Browse files
authored
Merge pull request #50 from PrestaShop/dev
Refactor ps_linklist module using 1.7 improvements
2 parents a901d45 + 01089b5 commit 9bf37ec

File tree

83 files changed

+8894
-1525
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+8894
-1525
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
/config_*.xml
22
/translations/*.php
3+
node_modules
4+
vendor
5+
!vendor/index.php
6+
!vendor/.htaccess

Readme.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,27 @@ That's it: you have contributed to this open-source project! Congratulations!
3434
[1]: http://doc.prestashop.com/display/PS16/Coding+Standards
3535
[2]: http://doc.prestashop.com/display/PS16/How+to+write+a+commit+message
3636
[3]: https://help.github.com/articles/using-pull-requests
37+
38+
## Building assets
39+
40+
If you need to change the javascript code you have to compile the assets, this operation is done
41+
via command line. You can get base information and requirements in the dev doc (be careful with the
42+
node version):
43+
44+
(https://devdocs.prestashop.com/1.7/development/compile-assets/)
45+
46+
Then the operations to compile assets are:
47+
48+
```$xslt
49+
cd ps_linklist/views
50+
npm install
51+
npm run build
52+
```
53+
54+
This will update the files in the `ps_linklist/view/public` folder.
55+
56+
During development you can build automatically the assets (in dev mode) when you modify them by using this command:
57+
58+
```
59+
npm run watch
60+
```

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.4.0"
13+
"php": ">=5.6.0"
14+
},
15+
"autoload": {
16+
"psr-4": {
17+
"PrestaShop\\Module\\LinkList\\": "src/"
18+
},
19+
"classmap": ["ps_linklist.php"],
20+
"exclude-from-classmap": []
1421
},
1522
"config": {
1623
"preferred-install": "dist"

composer.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
<module>
33
<name>ps_linklist</name>
44
<displayName><![CDATA[Link List]]></displayName>
5-
<version><![CDATA[2.1.5]]></version>
5+
<version><![CDATA[3.0.0]]></version>
66
<description><![CDATA[Adds a block with several links.]]></description>
77
<author><![CDATA[PrestaShop]]></author>
8+
<tab><![CDATA[front_office_features]]></tab>
89
<is_configurable>1</is_configurable>
910
<need_instance>0</need_instance>
1011
<limited_countries></limited_countries>

config/index.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* 2007-2018 PrestaShop.
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Academic Free License (AFL 3.0)
8+
* that is bundled with this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://opensource.org/licenses/afl-3.0.php
11+
* If you did not receive a copy of the license and are unable to
12+
* obtain it through the world-wide-web, please send an email
13+
* to license@prestashop.com so we can send you a copy immediately.
14+
*
15+
* DISCLAIMER
16+
*
17+
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
18+
* versions in the future. If you wish to customize PrestaShop for your
19+
* needs please refer to http://www.prestashop.com for more information.
20+
*
21+
* @author PrestaShop SA <contact@prestashop.com>
22+
* @copyright 2007-2018 PrestaShop SA
23+
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24+
* International Registered Trademark & Property of PrestaShop SA
25+
*/
26+
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
27+
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
28+
29+
header('Cache-Control: no-store, no-cache, must-revalidate');
30+
header('Cache-Control: post-check=0, pre-check=0', false);
31+
header('Pragma: no-cache');
32+
33+
header('Location: ../');
34+
exit;

config/routes.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
admin_link_block_list:
2+
path: /link-widget/list
3+
methods: [GET]
4+
defaults:
5+
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::listAction'
6+
_legacy_controller: AdminLinkWidget
7+
_legacy_link: AdminLinkWidget
8+
9+
admin_link_block_create:
10+
path: /link-widget/create
11+
methods: [GET]
12+
defaults:
13+
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::createAction'
14+
_legacy_controller: AdminLinkWidget
15+
16+
admin_link_block_create_process:
17+
path: /link-widget/create
18+
methods: [POST]
19+
defaults:
20+
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::createProcessAction'
21+
_legacy_controller: AdminLinkWidget
22+
23+
admin_link_block_edit:
24+
path: /link-widget/edit/{linkBlockId}
25+
methods: [GET]
26+
defaults:
27+
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::editAction'
28+
_legacy_controller: AdminLinkWidget
29+
30+
admin_link_block_edit_process:
31+
path: /link-widget/edit/{linkBlockId}
32+
methods: [POST]
33+
defaults:
34+
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::editProcessAction'
35+
_legacy_controller: AdminLinkWidget
36+
37+
admin_link_block_delete:
38+
path: /link-widget/delete/{linkBlockId}
39+
methods: [POST]
40+
defaults:
41+
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::deleteAction'
42+
_legacy_controller: AdminLinkWidget
43+
requirements:
44+
linkBlockId: \d+
45+
46+
admin_link_block_update_positions:
47+
path: /link-widget/update-positions/{hookId}
48+
methods: [POST]
49+
defaults:
50+
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::updatePositionsAction'
51+
_legacy_controller: AdminLinkWidget
52+
requirements:
53+
hookId: \d+

config/services.yml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
services:
2+
prestashop.module.link_block.cache:
3+
class: PrestaShop\Module\LinkList\Cache\LegacyLinkBlockCache
4+
arguments:
5+
$moduleRepository: '@prestashop.core.admin.module.repository'
6+
7+
prestashop.module.link_block.repository:
8+
class: PrestaShop\Module\LinkList\Repository\LinkBlockRepository
9+
arguments:
10+
$connection: '@doctrine.dbal.default_connection'
11+
$dbPrefix: '%database_prefix%'
12+
$languages: '@=service("prestashop.adapter.legacy.context").getLanguages(true, service("prestashop.adapter.shop.context").getContextShopID())'
13+
$translator: '@translator'
14+
15+
# Grid data query builder
16+
prestashop.module.link_block.grid.query_builder:
17+
class: PrestaShop\Module\LinkList\Core\Grid\Query\LinkBlockQueryBuilder
18+
arguments:
19+
$connection: '@doctrine.dbal.default_connection'
20+
$dbPrefix: '%database_prefix%'
21+
22+
# Grid Data Factory
23+
prestashop.module.link_block.grid.data_factory:
24+
class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%'
25+
arguments:
26+
$gridQueryBuilder: '@prestashop.module.link_block.grid.query_builder'
27+
$hookDispatcher: '@prestashop.core.hook.dispatcher'
28+
$queryParser: '@prestashop.core.grid.query.doctrine_query_parser'
29+
$gridId: 'link_block'
30+
31+
# Link block grid Factory
32+
prestashop.module.link_block.grid.factory:
33+
class: PrestaShop\Module\LinkList\Core\Grid\LinkBlockGridFactory
34+
arguments:
35+
$translator: '@translator'
36+
$hookDispatcher: '@prestashop.core.hook.dispatcher'
37+
$dataFactory: '@prestashop.module.link_block.grid.data_factory'
38+
$filterFormFactory: '@prestashop.core.grid.filter.form_factory'
39+
40+
# Grid position definition
41+
prestashop.module.link_block.grid.position_definition:
42+
class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition'
43+
arguments:
44+
$table: 'link_block'
45+
$idField: 'id_link_block'
46+
$positionField: 'position'
47+
$parentIdField: 'id_hook'
48+
49+
# Link block form data provider
50+
prestashop.module.link_block.form_provider:
51+
class: PrestaShop\Module\LinkList\Form\LinkBlockFormDataProvider
52+
arguments:
53+
$repository: '@prestashop.module.link_block.repository'
54+
$cache: '@prestashop.module.link_block.cache'
55+
$moduleRepository: '@prestashop.core.admin.module.repository'
56+
$languages: '@=service("prestashop.adapter.legacy.context").getLanguages(true, service("prestashop.adapter.shop.context").getContextShopID())'
57+
$shopId: '@=service("prestashop.adapter.shop.context").getContextShopID()'
58+
59+
# Form choices providers
60+
prestashop.module.link_block.choice_provider.hook:
61+
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\HookChoiceProvider
62+
arguments:
63+
$connection: '@doctrine.dbal.default_connection'
64+
$dbPrefix: '%database_prefix%'
65+
66+
prestashop.module.link_block.choice_provider.cms_category:
67+
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\CMSCategoryChoiceProvider
68+
arguments:
69+
$connection: '@doctrine.dbal.default_connection'
70+
$dbPrefix: '%database_prefix%'
71+
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
72+
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
73+
74+
prestashop.module.link_block.choice_provider.cms_page:
75+
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\CMSPageChoiceProvider
76+
arguments:
77+
$connection: '@doctrine.dbal.default_connection'
78+
$dbPrefix: '%database_prefix%'
79+
$categories: '@=service("prestashop.module.link_block.choice_provider.cms_category").getChoices()'
80+
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
81+
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
82+
83+
prestashop.module.link_block.choice_provider.product_page:
84+
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\PageChoiceProvider
85+
arguments:
86+
$connection: '@doctrine.dbal.default_connection'
87+
$dbPrefix: '%database_prefix%'
88+
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
89+
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
90+
$pageNames:
91+
- 'prices-drop'
92+
- 'new-products'
93+
- 'best-sales'
94+
95+
prestashop.module.link_block.choice_provider.static_page:
96+
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\PageChoiceProvider
97+
arguments:
98+
$connection: '@doctrine.dbal.default_connection'
99+
$dbPrefix: '%database_prefix%'
100+
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
101+
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
102+
$pageNames:
103+
- 'contact'
104+
- 'sitemap'
105+
- 'stores'
106+
- 'authentication'
107+
- 'my-account'
108+
109+
# Form types
110+
prestashop.module.link_block.form_type:
111+
class: PrestaShop\Module\LinkList\Form\Type\LinkBlockType
112+
parent: 'form.type.translatable.aware'
113+
public: true
114+
arguments:
115+
$hookChoices: '@=service("prestashop.module.link_block.choice_provider.hook").getChoices()'
116+
$cmsPageChoices: '@=service("prestashop.module.link_block.choice_provider.cms_page").getChoices()'
117+
$productPageChoices: '@=service("prestashop.module.link_block.choice_provider.product_page").getChoices()'
118+
$staticPageChoices: '@=service("prestashop.module.link_block.choice_provider.static_page").getChoices()'
119+
tags:
120+
- { name: form.type }
121+
122+
prestashop.module.link_block.custom_url_type:
123+
class: PrestaShop\Module\LinkList\Form\Type\CustomUrlType
124+
parent: 'form.type.translatable.aware'
125+
tags:
126+
- { name: form.type }
127+
128+
# Link block form handler
129+
prestashop.module.link_block.form_handler:
130+
class: 'PrestaShop\PrestaShop\Core\Form\FormHandler'
131+
arguments:
132+
$formBuilder: '@=service("form.factory").createBuilder()'
133+
$hookDispatcher: '@prestashop.core.hook.dispatcher'
134+
$formDataProvider: '@prestashop.module.link_block.form_provider'
135+
$formTypes:
136+
'link_block': 'PrestaShop\Module\LinkList\Form\Type\LinkBlockType'
137+
$hookName: 'AdminLinkWidget'

0 commit comments

Comments
 (0)