1. Go to this page and download the library: Download dartmoon/prestashop-hooks library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dartmoon / prestashop-hooks example snippets
use Dartmoon\Hooks\Traits\HasHookDispatcher;
class YourModule
{
use HasHookDispatcher;
/**
* Hook classes
*/
protected $hooks = [
//
];
// ...
}
public function __construct()
{
//...
// Let's init the hook dispatcher
$this->initHookDispatcher();
}
public function install()
{
if (
parent::install()
&& $this->registerHook($this->getHookDispatcher()->getAvailableHooks())
) {
//...
return true;
}
return false;
}
namespace Dartmoon\MyModule\Hooks;
use Dartmoon\Hooks\AbstractHookGroup;
class FrontAssetsHooks extends AbstractHookGroup
{
/**
* Name of the hooks to register
*/
protected $hooks = [
'header',
// You can register how many hooks you want
];
public function header($params)
{
//...
// $this->module is the instance of the module
// $this->context is the instance of the current context
}
}