-
Notifications
You must be signed in to change notification settings - Fork 10
/
classicblocks.php
81 lines (70 loc) · 2.24 KB
/
classicblocks.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
use ClassicBlocks\Block\BlockLoader;
use ClassicBlocks\Module\Hook as ClassicBlocksHook;
use ClassicBlocks\Module\Installer;
if (!defined('_PS_VERSION_')) {
exit;
}
require_once __DIR__ . '/vendor/autoload.php';
class ClassicBlocks extends Module
{
public function __construct()
{
$this->name = 'classicblocks';
$this->tab = 'administration';
$this->version = '1.0.4';
$this->author = 'PrestaSafe';
$this->dependencies = ['prettyblocks'];
parent::__construct();
$this->displayName = $this->trans('Classic blocks');
$this->description = $this->trans('All default blocks for Classic theme');
$this->ps_versions_compliancy = array('min' => '1.7', 'max' => _PS_VERSION_);
}
/**
* Magic method PHP.
*
* @param string $name
* @param array $arguments
*/
public function __call(string $name, array $arguments)
{
try {
// Déporter les hooks dans une classe custom (sauf le hookBeforeRendering)
if (method_exists(ClassicBlocksHook::class, $name) && !strstr($name, 'hookBeforeRendering')) {
if (substr($name, 0, 4) === 'hook') {
return ClassicBlocksHook::execute($name, $this, $arguments[0] ?? null);
}
} else {
// HookBeforeRendering
return BlockLoader::getBlockBeforeRendering(
str_replace('hookBeforeRendering', '', $name),
$arguments[0] ?? null
);
}
} catch (Exception $e) {
PrestaShopLogger::addLog($e->getMessage());
}
}
/**
* @return bool
*/
public function install(): bool
{
return
parent::install() &&
(new Installer($this))->run()
;
}
/**
* @return bool
*/
public function uninstall(): bool
{
return parent::uninstall() &&
// $this->unregisterHook('ActionRegisterThemeSettings') &&
$this->unregisterHook('ActionRegisterBlock') &&
$this->unregisterHook('displayHeader') &&
// $this->unregisterHook('ActionQueueSassCompile') &&
$this->unregisterHook('beforeRenderingClassicFeaturedProduct');
}
}