signalwow/configurationpage

PrestaShop模块配置页面的创建工具

0.0.1 2020-02-15 03:41 UTC

This package is not auto-updated.

Last update: 2024-09-24 20:33:23 UTC


README

安装

在模块

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';
    }

使用

在 getContent()

处理表单并显示配置页面。

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

在 install()

初始化默认值。

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

在 uninstall()

在卸载模块时删除配置值。

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