Skip to content

Commit

Permalink
Merge pull request #59 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Deploy v3.0.2 of ps_linklist
  • Loading branch information
jolelievre authored Dec 13, 2018
2 parents 3c091a8 + 57b9ab6 commit 3721b07
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 33 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"description": "PrestaShop - Link list",
"homepage": "https://github.com/PrestaShop/ps_linklist",
"license": "AFL-3.0",
"version": "3.0.2",
"authors": [
{
"name": "PrestaShop SA",
Expand Down
2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_linklist</name>
<displayName><![CDATA[Link List]]></displayName>
<version><![CDATA[3.0.1]]></version>
<version><![CDATA[3.0.2]]></version>
<description><![CDATA[Adds a block with several links.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[front_office_features]]></tab>
Expand Down
4 changes: 4 additions & 0 deletions config/services.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
services:
_defaults:
public: true

prestashop.module.link_block.cache:
class: PrestaShop\Module\LinkList\Cache\LegacyLinkBlockCache
arguments:
Expand Down Expand Up @@ -122,6 +125,7 @@ services:
prestashop.module.link_block.custom_url_type:
class: PrestaShop\Module\LinkList\Form\Type\CustomUrlType
parent: 'form.type.translatable.aware'
public: true
tags:
- { name: form.type }

Expand Down
51 changes: 32 additions & 19 deletions ps_linklist.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use PrestaShop\Module\LinkList\Model\LinkBlockLang;
use PrestaShop\Module\LinkList\Repository\LinkBlockRepository;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer;
use PrestaShop\PrestaShop\Adapter\LegacyContext;
use PrestaShop\PrestaShop\Adapter\Shop\Context;

Expand Down Expand Up @@ -67,9 +66,17 @@ public function __construct()
{
$this->name = 'ps_linklist';
$this->author = 'PrestaShop';
$this->version = '3.0.1';
$this->version = '3.0.2';
$this->need_instance = 0;
$this->tab = 'front_office_features';
$this->tabs = [
[
'class_name' => 'AdminLinkWidget',
'visible' => true,
'name' => 'Link Widget',
'parent_class_name' => 'AdminParentThemes',
],
];

$this->bootstrap = true;
parent::__construct();
Expand All @@ -90,7 +97,7 @@ public function install()
if (!parent::install()) {
return false;
}
$installed = true;

if (null !== $this->getRepository()) {
$installed = $this->installFixtures();
} else {
Expand All @@ -101,17 +108,23 @@ public function install()
&& $this->registerHook('displayFooter')
&& $this->registerHook('actionUpdateLangAfter')
&& $this->installTab()) {
//Clear Symfony cache to update routing rules
Tools::clearSf2Cache();

return true;
}

parent::uninstall();
$this->uninstall();

return false;
}

public function enable($force_all = false)
{
if (!$this->installTab()) {
return false;
}

return parent::enable($force_all);
}

/**
* @return bool
*
Expand Down Expand Up @@ -146,10 +159,6 @@ private function installLegacyFixtures()
public function uninstall()
{
$uninstalled = true;
if (!$this->uninstallTab()) {
$this->_errors[] = $this->trans('Could not remove Tab.', array(), 'Admin.Modules.Notification');
$uninstalled = false;
}
$errors = $this->getRepository()->dropTables();
if (!empty($errors)) {
$this->addModuleErrors($errors);
Expand All @@ -159,8 +168,20 @@ public function uninstall()
return $uninstalled && parent::uninstall();
}

/**
* The Core is supposed to register the tabs automatically thanks to the getTabs() return.
* However in 1.7.5 it only works when the module contains a AdminLinkWidgetController file,
* this works fine when module has been upgraded and the former file is still present however
* for a fresh install we need to install it manually until the core is able to manage new modules.
*
* @return bool
*/
public function installTab()
{
if (Tab::getIdFromClassName('AdminLinkWidget')) {
return true;
}

$tab = new Tab();
$tab->active = 1;
$tab->class_name = 'AdminLinkWidget';
Expand All @@ -174,14 +195,6 @@ public function installTab()
return $tab->add();
}

public function uninstallTab()
{
$id_tab = (int) Tab::getIdFromClassName('AdminLinkWidget');
$tab = new Tab($id_tab);

return $tab->delete();
}

public function hookActionUpdateLangAfter($params)
{
if (!empty($params['lang']) && $params['lang'] instanceof Language) {
Expand Down
6 changes: 5 additions & 1 deletion src/Controller/Admin/Improve/Design/LinkBlockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function editAction(Request $request, $linkBlockId)
}

/**
* @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.")
* @AdminSecurity("is_granted('create', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
*
Expand Down Expand Up @@ -160,6 +160,8 @@ public function editProcessAction(Request $request, $linkBlockId)
}

/**
* @AdminSecurity("is_granted('delete', request.get('_legacy_controller'))", message="Access denied.")
*
* @param int $linkBlockId
*
* @return RedirectResponse
Expand Down Expand Up @@ -189,6 +191,8 @@ public function deleteAction($linkBlockId)
}

/**
* @AdminSecurity("is_granted('update', request.get('_legacy_controller'))", message="Access denied.")
*
* @param Request $request
* @param int $hookId
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function getColumns()
'update_method' => 'POST',
'record_route_params' => [
'id_hook' => 'hookId',
]
],
])
)
->add((new ActionColumn('actions'))
Expand Down
1 change: 1 addition & 0 deletions src/Form/LinkBlockFormDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ private function validateLinkBlock(array $data)

/**
* @param array $custom
*
* @return bool
*/
private function isEmptyCustom(array $custom)
Expand Down
2 changes: 1 addition & 1 deletion src/Presenter/LinkBlockPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private function makeCustomLinks($customContent)
$self = $this;
$customLinks = array_map(function ($el) use ($self) {
return array(
'id' => 'link-custom-page-' . $el['title'],
'id' => 'link-custom-page-' . Tools::link_rewrite($el['title']),
'class' => 'custom-page-link',
'title' => $el['title'],
'description' => '',
Expand Down
10 changes: 1 addition & 9 deletions upgrade/upgrade-3.0.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
exit;
}

use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Adapter\Cache\CacheClearer;

function upgrade_module_3_0($object)
{
Configuration::deleteByName('FOOTER_CMS');
Expand All @@ -41,12 +38,7 @@ function upgrade_module_3_0($object)
Configuration::deleteByName('FOOTER_CONTACT');
Configuration::deleteByName('FOOTER_SITEMAP');

Db::getInstance()->execute('DROP TABLE `' . _DB_PREFIX_ . 'cms_block_page`');

$object->reset();

//Clear Symfony cache to update routing rules
Tools::clearSf2Cache();
Db::getInstance()->execute('DROP TABLE IF EXISTS `' . _DB_PREFIX_ . 'cms_block_page`');

return true;
}
2 changes: 1 addition & 1 deletion views/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ps_linklist",
"version": "3.0.1",
"version": "3.0.2",
"description": "",
"scripts": {
"build": "NODE_ENV=production webpack --progress --colors --debug --display-chunks",
Expand Down

0 comments on commit 3721b07

Please sign in to comment.