Jump to content

[solved] The controller AdminObjectifController is missing or invalid.


Recommended Posts

I had created the module "mymodule"  and it installed, tried to open the controller in the page "http://prestashop.pp:8082/admin47181ymgj5ac4e10t7g/index.php?controller=AdminObjectifController&token=a9a1a411b98c9dccf03de19b2bbae6a3#/dashboard"
and had this error. This is my code in the module:

<?php
if (!defined('_PS_VERSION_')) {
    exit;
}

class Mymodule extends Module
{
    public function __construct()
    {
        $this->name = 'mymodule';
        $this->tab = 'front_office_features';
        $this->version = '1.0.0';
        $this->author = 'Firstname Lastname';
        $this->need_instance = 0;
        $this->ps_versions_compliancy = [
            'min' => '1.7.0.0',
            'max' => '8.99.99',
        ];
        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->l('My module');
        $this->description = $this->l('Description of my module.');

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

        if (!Configuration::get('MYMODULE_NAME')) {
            $this->warning = $this->l('No name provided');
        }
    }
    public function install()
    {
        $class = 'AdminObjectif';
        $tab = new Tab();
        $tab->class_name = $class;
        $tab->module = $this->name;
        $tab->id_parent = (int) Tab::getIdFromClassName('AdminParentCustomer');
        $langs = Language::getLanguages(false);
        foreach ($langs as $l) {
            $tab->name[$l['id_lang']] = $this->l('Objectifs');
        }
        $tab->save();
        return parent::install() && $this->registerHook('displayHome') && $this->createTabLink();
    }
    public function uninstall()
    {
        return (
            parent::uninstall()
            && Configuration::deleteByName('MYMODULE_NAME')
        );
    }
    public function createTabLink(){
        $tab=new Tab;
        foreach (Language::getLanguages() as $lang)
        {$tab-> name[$lang['id_lang']]=$this->l('Origin');
        }
        $tab->class_name="AdminOrigin";
        $tab->module=$this->name;
        $tab->id_parent=0;
        $tab->add();
        return true;
    }
    protected function generateControllerURI()
    {
        $router = SymfonyContainer::getInstance()->get('router');

        return $router->generate('my_route_name');
    }
}

and this in the controller:

<?php

class AdminObjectifController extends ModuleAdminController
{
    public function __construct()
    {
        $this->bootstrap = true;
        $this->table = 'objectifs';
        $this->className = 'Objectif';

        parent::__construct();
    }

    public function initContent()
    {
        $tpl = $this->context->smarty->createTemplate($this->getTemplatePath() . 'origin.tpl', $this->context->smarty);


        $tpl->assign(array(
            'my_var' => "test"
        ));

        $this->content .= $tpl->fetch();
        parent::initContent();
    }
}

Maybe you help me with this problem.Greetings

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

  • Andrz2556 changed the title to [solved] The controller AdminObjectifController is missing or invalid.

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...