Skip to content

Commit

Permalink
Merge pull request #50 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Refactor ps_linklist module using 1.7 improvements
  • Loading branch information
jolelievre authored Nov 14, 2018
2 parents a901d45 + 01089b5 commit 9bf37ec
Show file tree
Hide file tree
Showing 83 changed files with 8,894 additions and 1,525 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/config_*.xml
/translations/*.php
node_modules
vendor
!vendor/index.php
!vendor/.htaccess
24 changes: 24 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,27 @@ That's it: you have contributed to this open-source project! Congratulations!
[1]: http://doc.prestashop.com/display/PS16/Coding+Standards
[2]: http://doc.prestashop.com/display/PS16/How+to+write+a+commit+message
[3]: https://help.github.com/articles/using-pull-requests

## Building assets

If you need to change the javascript code you have to compile the assets, this operation is done
via command line. You can get base information and requirements in the dev doc (be careful with the
node version):

(https://devdocs.prestashop.com/1.7/development/compile-assets/)

Then the operations to compile assets are:

```$xslt
cd ps_linklist/views
npm install
npm run build
```

This will update the files in the `ps_linklist/view/public` folder.

During development you can build automatically the assets (in dev mode) when you modify them by using this command:

```
npm run watch
```
9 changes: 8 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
}
],
"require": {
"php": ">=5.4.0"
"php": ">=5.6.0"
},
"autoload": {
"psr-4": {
"PrestaShop\\Module\\LinkList\\": "src/"
},
"classmap": ["ps_linklist.php"],
"exclude-from-classmap": []
},
"config": {
"preferred-install": "dist"
Expand Down
19 changes: 19 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
<module>
<name>ps_linklist</name>
<displayName><![CDATA[Link List]]></displayName>
<version><![CDATA[2.1.5]]></version>
<version><![CDATA[3.0.0]]></version>
<description><![CDATA[Adds a block with several links.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
<is_configurable>1</is_configurable>
<need_instance>0</need_instance>
<limited_countries></limited_countries>
Expand Down
34 changes: 34 additions & 0 deletions config/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* 2007-2018 PrestaShop.
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* 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 [email protected] 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 http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2018 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
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;
53 changes: 53 additions & 0 deletions config/routes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
admin_link_block_list:
path: /link-widget/list
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::listAction'
_legacy_controller: AdminLinkWidget
_legacy_link: AdminLinkWidget

admin_link_block_create:
path: /link-widget/create
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::createAction'
_legacy_controller: AdminLinkWidget

admin_link_block_create_process:
path: /link-widget/create
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::createProcessAction'
_legacy_controller: AdminLinkWidget

admin_link_block_edit:
path: /link-widget/edit/{linkBlockId}
methods: [GET]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::editAction'
_legacy_controller: AdminLinkWidget

admin_link_block_edit_process:
path: /link-widget/edit/{linkBlockId}
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::editProcessAction'
_legacy_controller: AdminLinkWidget

admin_link_block_delete:
path: /link-widget/delete/{linkBlockId}
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::deleteAction'
_legacy_controller: AdminLinkWidget
requirements:
linkBlockId: \d+

admin_link_block_update_positions:
path: /link-widget/update-positions/{hookId}
methods: [POST]
defaults:
_controller: 'PrestaShop\Module\LinkList\Controller\Admin\Improve\Design\LinkBlockController::updatePositionsAction'
_legacy_controller: AdminLinkWidget
requirements:
hookId: \d+
137 changes: 137 additions & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
services:
prestashop.module.link_block.cache:
class: PrestaShop\Module\LinkList\Cache\LegacyLinkBlockCache
arguments:
$moduleRepository: '@prestashop.core.admin.module.repository'

prestashop.module.link_block.repository:
class: PrestaShop\Module\LinkList\Repository\LinkBlockRepository
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$languages: '@=service("prestashop.adapter.legacy.context").getLanguages(true, service("prestashop.adapter.shop.context").getContextShopID())'
$translator: '@translator'

# Grid data query builder
prestashop.module.link_block.grid.query_builder:
class: PrestaShop\Module\LinkList\Core\Grid\Query\LinkBlockQueryBuilder
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'

# Grid Data Factory
prestashop.module.link_block.grid.data_factory:
class: '%prestashop.core.grid.data.factory.doctrine_grid_data_factory%'
arguments:
$gridQueryBuilder: '@prestashop.module.link_block.grid.query_builder'
$hookDispatcher: '@prestashop.core.hook.dispatcher'
$queryParser: '@prestashop.core.grid.query.doctrine_query_parser'
$gridId: 'link_block'

# Link block grid Factory
prestashop.module.link_block.grid.factory:
class: PrestaShop\Module\LinkList\Core\Grid\LinkBlockGridFactory
arguments:
$translator: '@translator'
$hookDispatcher: '@prestashop.core.hook.dispatcher'
$dataFactory: '@prestashop.module.link_block.grid.data_factory'
$filterFormFactory: '@prestashop.core.grid.filter.form_factory'

# Grid position definition
prestashop.module.link_block.grid.position_definition:
class: 'PrestaShop\PrestaShop\Core\Grid\Position\PositionDefinition'
arguments:
$table: 'link_block'
$idField: 'id_link_block'
$positionField: 'position'
$parentIdField: 'id_hook'

# Link block form data provider
prestashop.module.link_block.form_provider:
class: PrestaShop\Module\LinkList\Form\LinkBlockFormDataProvider
arguments:
$repository: '@prestashop.module.link_block.repository'
$cache: '@prestashop.module.link_block.cache'
$moduleRepository: '@prestashop.core.admin.module.repository'
$languages: '@=service("prestashop.adapter.legacy.context").getLanguages(true, service("prestashop.adapter.shop.context").getContextShopID())'
$shopId: '@=service("prestashop.adapter.shop.context").getContextShopID()'

# Form choices providers
prestashop.module.link_block.choice_provider.hook:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\HookChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'

prestashop.module.link_block.choice_provider.cms_category:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\CMSCategoryChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'

prestashop.module.link_block.choice_provider.cms_page:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\CMSPageChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$categories: '@=service("prestashop.module.link_block.choice_provider.cms_category").getChoices()'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'

prestashop.module.link_block.choice_provider.product_page:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\PageChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
$pageNames:
- 'prices-drop'
- 'new-products'
- 'best-sales'

prestashop.module.link_block.choice_provider.static_page:
class: PrestaShop\Module\LinkList\Form\ChoiceProvider\PageChoiceProvider
arguments:
$connection: '@doctrine.dbal.default_connection'
$dbPrefix: '%database_prefix%'
$idLang: '@=service("prestashop.adapter.legacy.context").getLanguage().id'
$shopIds: '@=service("prestashop.adapter.shop.context").getContextListShopID()'
$pageNames:
- 'contact'
- 'sitemap'
- 'stores'
- 'authentication'
- 'my-account'

# Form types
prestashop.module.link_block.form_type:
class: PrestaShop\Module\LinkList\Form\Type\LinkBlockType
parent: 'form.type.translatable.aware'
public: true
arguments:
$hookChoices: '@=service("prestashop.module.link_block.choice_provider.hook").getChoices()'
$cmsPageChoices: '@=service("prestashop.module.link_block.choice_provider.cms_page").getChoices()'
$productPageChoices: '@=service("prestashop.module.link_block.choice_provider.product_page").getChoices()'
$staticPageChoices: '@=service("prestashop.module.link_block.choice_provider.static_page").getChoices()'
tags:
- { name: form.type }

prestashop.module.link_block.custom_url_type:
class: PrestaShop\Module\LinkList\Form\Type\CustomUrlType
parent: 'form.type.translatable.aware'
tags:
- { name: form.type }

# Link block form handler
prestashop.module.link_block.form_handler:
class: 'PrestaShop\PrestaShop\Core\Form\FormHandler'
arguments:
$formBuilder: '@=service("form.factory").createBuilder()'
$hookDispatcher: '@prestashop.core.hook.dispatcher'
$formDataProvider: '@prestashop.module.link_block.form_provider'
$formTypes:
'link_block': 'PrestaShop\Module\LinkList\Form\Type\LinkBlockType'
$hookName: 'AdminLinkWidget'
Loading

0 comments on commit 9bf37ec

Please sign in to comment.