signalwow/configurationpage

Tool for creating configuration pages of PrestaShop modules

0.0.1 2020-02-15 03:41 UTC

This package is not auto-updated.

Last update: 2024-05-21 18:44:53 UTC


README

Installation

Dans le module :

composer require signalwow/configurationpage

<?php

    if (file_exists(__DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) {
        require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
    }

Utilisation

Dans getContent()

Pour traiter le formulaire et afficher la page de configuration.

    public function getContent()
    {
        return \SignalWow\ConfigurationPage\ConfigurationPage::getInstance()
            ->setOptionPrefix('test_')
            ->setOptionTable($this->table)
            ->setOptionIdentifier($this->identifier)
            ->addForm($this->getConfigForm())
            ->processAndRender($this);
    }

Dans install()

Pour initialiser les valeurs par défaut.

    public function install()
    {
        //...
        $isInitialized = ConfigurationPage::getInstance()
            ->setOptionPrefix('test_')
            ->initDefaults(
                ['TESTMODULE_LIVE_MODE' => false],
                $this
            );
        //...
    }

Dans uninstall()

Pour effacer les valeurs de configuration a la désinstallation du module.

    public function uninstall()
    {
        //...
        $isDeleted = \SignalWow\ConfigurationPage\ConfigurationPage::getInstance()
            ->setOptionPrefix('test_')
            ->setOptionTable($this->table)
            ->setOptionIdentifier($this->identifier)
            ->addForm($this->getConfigForm())
            ->deleteConfigurations();
        //...
    }