Skip to content

Commit

Permalink
Fixed issues and restore events
Browse files Browse the repository at this point in the history
  • Loading branch information
mickaelandrieu committed Aug 17, 2018
1 parent 50490de commit 30c9407
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
5 changes: 4 additions & 1 deletion src/Adapter/HookManager.php
Expand Up @@ -70,7 +70,10 @@ public function exec(
// If Symfony application is booted, we use it to dispatch Hooks
$hookDispatcher = $sfContainer->get('prestashop.core.hook.dispatcher');

return $hookDispatcher->renderForParameters($hook_name, $hook_args)->getContent();
return $hookDispatcher
->dispatchRenderingWithParameters($hook_name, $hook_args)
->getContent()
;
} else {
try {
return Hook::exec($hook_name, $hook_args, $id_module, $array_return, $check_exceptions, $use_push, $id_shop);
Expand Down
19 changes: 9 additions & 10 deletions src/Adapter/Module/ModuleZipManager.php
Expand Up @@ -27,7 +27,7 @@
namespace PrestaShop\PrestaShop\Adapter\Module;

use PrestaShopBundle\Event\ModuleZipManagementEvent;
use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Symfony\Component\Translation\TranslatorInterface;
Expand Down Expand Up @@ -61,19 +61,19 @@ class ModuleZipManager
private $translator;

/**
* @var HookDispatcherInterface
* @var EventDispatcherInterface
*/
private $hookDispatcher;
private $eventDispatcher;

public function __construct(
Filesystem $filesystem,
TranslatorInterface $translator,
HookDispatcherInterface $hookDispatcher
EventDispatcherInterface $eventDispatcher
)
{
$this->filesystem = $filesystem;
$this->translator = $translator;
$this->hookDispatcher = $hookDispatcher;
$this->eventDispatcher = $eventDispatcher;
}

/**
Expand Down Expand Up @@ -168,11 +168,10 @@ public function storeInModulesFolder($source)
null,
array('override' => true)
);
$this->hookDispatcher
->dispatchWithParameters(ModuleZipManagementEvent::DOWNLOAD,
[
'event' => new ModuleZipManagementEvent($this->getSource($source))
]
$this->eventDispatcher
->dispatch(
ModuleZipManagementEvent::DOWNLOAD,
new ModuleZipManagementEvent($this->getSource($source))
)
;

Expand Down
16 changes: 8 additions & 8 deletions src/Core/Addon/Module/ModuleManager.php
Expand Up @@ -35,7 +35,7 @@
use PrestaShop\PrestaShop\Core\Addon\AddonsCollection;
use PrestaShop\PrestaShop\Core\Addon\Module\Exception\UnconfirmedModuleActionException;
use PrestaShopBundle\Event\ModuleManagementEvent;
use PrestaShop\PrestaShop\Core\Hook\HookDispatcherInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\ParameterBag;
use Symfony\Component\Translation\TranslatorInterface;

Expand Down Expand Up @@ -76,9 +76,9 @@ class ModuleManager implements AddonManagerInterface
private $translator;

/**
* @var HookDispatcherInterface
* @var EventDispatcherInterface
*/
private $hookDispatcher;
private $eventDispatcher;

/**
* Additionnal data used for module actions
Expand All @@ -94,7 +94,7 @@ class ModuleManager implements AddonManagerInterface
* @param ModuleRepository $moduleRepository
* @param ModuleZipManager $moduleZipManager
* @param TranslatorInterface $translator
* @param HookDispatcherInterface $hookDispatcher
* @param EventDispatcherInterface $eventDispatcher
*/
public function __construct(
AdminModuleDataProvider $adminModuleProvider,
Expand All @@ -103,7 +103,7 @@ public function __construct(
ModuleRepository $moduleRepository,
ModuleZipManager $moduleZipManager,
TranslatorInterface $translator,
HookDispatcherInterface $hookDispatcher
EventDispatcherInterface $eventDispatcher
)
{
$this->adminModuleProvider = $adminModuleProvider;
Expand All @@ -112,7 +112,7 @@ public function __construct(
$this->moduleRepository = $moduleRepository;
$this->moduleZipManager = $moduleZipManager;
$this->translator = $translator;
$this->hookDispatcher = $hookDispatcher;
$this->eventDispatcher = $eventDispatcher;

$this->actionParams = new ParameterBag();
}
Expand Down Expand Up @@ -621,7 +621,7 @@ public function getError($name)
*/
private function dispatch($event, $module)
{
$this->hookDispatcher->dispatchWithParameters($event, ['event' => new ModuleManagementEvent($module)]);
$this->eventDispatcher->dispatch($event, new ModuleManagementEvent($module));
}

private function checkIsInstalled($name)
Expand All @@ -636,7 +636,7 @@ private function checkIsInstalled($name)
}

/**
* We check the module does not ask for pre-requesites to be respected prior the action being executed.
* We check the module does not ask for pre-requisites to be respected prior the action being executed.
*
* @param string $action
* @param Module $module
Expand Down
Expand Up @@ -46,14 +46,14 @@ services:
- "@prestashop.core.admin.module.repository"
- "@prestashop.module.zip.manager"
- "@translator"
- "@prestashop.core.hook.dispatcher"
- "@event_dispatcher"

prestashop.module.zip.manager:
class: PrestaShop\PrestaShop\Adapter\Module\ModuleZipManager
arguments:
- "@filesystem"
- "@translator"
- "@prestashop.core.hook.dispatcher"
- "@event_dispatcher"

prestashop.adapter.presenter.module:
class: PrestaShop\PrestaShop\Adapter\Module\ModulePresenter
Expand Down

0 comments on commit 30c9407

Please sign in to comment.