Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion everblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public function __construct()
];
}

/**
* Intercepte dynamiquement les hooks display non déclarés explicitement.
*
* Cette méthode évite de devoir créer une méthode hook* pour chaque hook display,
* tout en limitant l'exécution au front-office (hors contrôleurs bypassés).
*
* @param string $method Nom de la méthode appelée (ex: hookDisplayHome)
* @param array<int, mixed> $args Arguments transmis par PrestaShop
*
* @return mixed
*/
public function __call($method, $args)
{
if (php_sapi_name() == 'cli') {
Expand All @@ -106,7 +117,9 @@ public function __call($method, $args)
}
}


/**
* Installe le module et son socle fonctionnel (config, SQL, hooks, onglets BO).
*/
public function install(): bool
{
if (!parent::install()) {
Expand All @@ -132,6 +145,9 @@ public function install(): bool
return true;
}

/**
* Initialise les clés de configuration nécessaires au fonctionnement du module.
*/
private function installConfiguration(): bool
{
$configuration = [
Expand Down Expand Up @@ -180,6 +196,9 @@ private function installConfiguration(): bool
return true;
}

/**
* Exécute le script SQL d'installation et crée les tables du module.
*/
private function installSql(): bool
{
$sql = [];
Expand All @@ -194,6 +213,9 @@ private function installSql(): bool
return true;
}

/**
* Crée les hooks personnalisés du module puis enregistre les hooks natifs requis.
*/
private function installHooks(): bool
{
$customHooks = [
Expand Down Expand Up @@ -231,6 +253,9 @@ private function installHooks(): bool
return true;
}

/**
* Enregistre les hooks d'intégration avec QCD Builder lorsqu'ils sont disponibles.
*/
private function registerQcdBuilderHooks(): bool
{
$hooksToRegister = [
Expand Down
14 changes: 14 additions & 0 deletions src/Command/ImportFileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function __construct(KernelInterface $kernel)
parent::__construct();
}

/**
* Déclare la commande d'import et prépare les chemins de fichiers utilisés.
*/
protected function configure()
{
$this->setName('everblock:tools:import');
Expand All @@ -61,6 +64,9 @@ protected function configure()
$this->module = \Module::getInstanceByName('everblock');
}

/**
* Orchestration de l'import XLSX : lecture, mise à jour des blocs puis nettoyage.
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (file_exists($this->filename)) {
Expand Down Expand Up @@ -93,6 +99,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}

/**
* Crée ou met à jour un bloc à partir d'une ligne du fichier d'import.
*
* Chaque colonne est validée avant affectation afin d'éviter l'écriture de données
* incohérentes en base.
*
* @param array<string, mixed> $line
*/
protected function updateEverblocks($line, $output)
{
if (!isset($line['id_lang'])
Expand Down
6 changes: 6 additions & 0 deletions src/Service/EverblockTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@

class EverblockTools extends ObjectModel
{
/**
* Point d'entrée principal du moteur de shortcodes.
*
* Le texte est enrichi en plusieurs étapes : hooks d'extension, résolution des
* shortcodes métier, remplacement des variables Smarty et post-traitements client.
*/
public static function renderShortcodes(string $txt, Context $context, Everblock $module): string
{
Hook::exec('displayBeforeRenderingShortcodes', ['html' => &$txt]);
Expand Down
Loading