Jump to content

[solved] The action uninstall is not available for module


Andrz2556

Recommended Posts

Hello, I made some small changes in my module and now I can`t see any of possibility changing my module like I can`t uninstall or install it or configure
This code for the module 
 

<?php
header("Access-Control-Allow-Origin: *");
include_once(__DIR__ . '/Ps_IntroSlider.php');

if (!defined('_PS_VERSION_')) {
    exit;
}

$autoloadPath = __DIR__ . '/vendor/autoload.php';

if (file_exists($autoloadPath)) {
    require_once $autoloadPath;
}
use introslider\Controller\AdminIntrosliderController;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use introslider\Ps_IntroSlider;

class introslider extends Module
{
    protected $_html = '';
    protected $default_width = 779;
    protected $default_speed = 5000;
    protected $default_pause_on_hover = 1;
    protected $default_wrap = 1;
    protected $templateFile;


    public function __construct()
    {
        $this->name = 'introslider';
        $this->tab = 'front_new_office_features';
        $this->version = '1.0.0';
        $this->author = 'HIC';
        $this->need_instance = 0;
        $this->secure_key = Tools::encrypt($this->name);
        $this->bootstrap = true;
        $this->ps_versions_compliancy = [
            'min' => '1.6',
            'max' => _PS_VERSION_,
        ];
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->getTranslator()->trans('Intro slider', array(), 'Modules.Introslider.Admin');

        $this->description = $this->l('Add new splash screen and product slides for mobile.');

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

        if (!Configuration::get('introslider')) {
            $this->warning = $this->l('No name provided');
        }
        $tabNames = [];
        foreach (Language::getLanguages(true) as $lang) {
            $tabNames[$lang['locale']] = $this->trans('Introslider Admin', [], 'Modules.Introslider.Admin', $lang['locale']);
        }
        
        $this->tab_class = array(
            'AdminIntrosliderModule' => array(
                'id_parent' => 0,
                'label' => $this->l('Introslider'),
                'icon' => 'false'
            ),
            'AdminIntroslider' => array(
                'id_parent' => Tab::getIdFromClassName('AdminIntroslider'),
                'label' => $this->l('Introslider list'),
                'icon' => 'false'
            )
        );
        

    }

    public function install()

    {

        /* Adds Module */
        if (parent::install() &&
            $this->registerHook('displayHeader') &&
            $this->registerHook('displayHome') &&
            $this->registerHook('actionShopDataDuplication')
        ) {
            $shops = Shop::getContextListShopID();
            $shop_groups_list = array();

            /* Setup each shop */
            foreach ($shops as $shop_id) {
                $shop_group_id = (int)Shop::getGroupFromShop($shop_id, true);

                if (!in_array($shop_group_id, $shop_groups_list)) {
                    $shop_groups_list[] = $shop_group_id;
                }

                /* Sets up configuration */
                $res = Configuration::updateValue('INTROSLIDER_SPEED', $this->default_speed, false, $shop_group_id, $shop_id);
                $res &= Configuration::updateValue('INTROSLIDER_PAUSE_ON_HOVER', $this->default_pause_on_hover, false, $shop_group_id, $shop_id);
                $res &= Configuration::updateValue('INTROSLIDER_WRAP', $this->default_wrap, false, $shop_group_id, $shop_id);
            }

            /* Sets up Shop Group configuration */
            if (count($shop_groups_list)) {
                foreach ($shop_groups_list as $shop_group_id) {
                    $res &= Configuration::updateValue('INTROSLIDER_SPEED', $this->default_speed, false, $shop_group_id);
                    $res &= Configuration::updateValue('INTROSLIDER_PAUSE_ON_HOVER', $this->default_pause_on_hover, false, $shop_group_id);
                    $res &= Configuration::updateValue('INTROSLIDER_WRAP', $this->default_wrap, false, $shop_group_id);
                }
            }

            /* Sets up Global configuration */
            $res &= Configuration::updateValue('INTROSLIDER_SPEED', $this->default_speed);
            $res &= Configuration::updateValue('INTROSLIDER_PAUSE_ON_HOVER', $this->default_pause_on_hover);
            $res &= Configuration::updateValue('INTROSLIDER_WRAP', $this->default_wrap);

            /* Creates tables */
            $res = $this->createTables();

            return (bool)$res;
        }

        return false;
    }


  

    public function uninstall()
    {

        return (
        parent::uninstall() 
        && Configuration::deleteByName('INTROSLIDER_SPEED') && 
             Configuration::deleteByName('INTROSLIDER_PAUSE_ON_HOVER') && 
             Configuration::deleteByName('INTROSLIDER_WRAP')
    );

    }
    

    
    private function manuallyInstallTab()
    {
        $res = true;
        $id_parent = 0;
        foreach ($this->tab_class as $class => $value){
            $tab = new Tab();
            $tab->class_name = $class;
            $tab->id_parent = $id_parent;
            $tab->module = $this->name;
            $tab->name[(int)Configuration::get('PS_LANG_DEFAULT')] = $value['label'];
            if (true == Tools::version_compare(_PS_VERSION_, '1.7.0.0', '>=') && $value['icon']) {
                $tab->icon = $value['icon'];
            }
            $res &= $tab->add();
            if (!$id_parent) {
                $id_parent = (int)$tab->id;
            }
        }
        return $res;
    }
    
    private function uninstallTab()
    {
        $res = true;
        foreach (array_keys($this->tab_class) as $class) {
            $idTab = Tab::getIdFromClassName($class);
            if ($idTab != 0) {
                $tab = new Tab($idTab);
                $res &= $tab->delete();
            }
        }
        return $res;
    }

 

1.JPG

Edited by Andrz2556 (see edit history)
Link to comment
Share on other sites

  • Andrz2556 changed the title to [solved] The action uninstall is not available for module

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...