我如何 return 将安装错误返回到 Prestashop 1.7 中的模块管理器?

How can I return an install error back to the Module Manager in Prestashop 1.7?

我正在尝试调试我的模块安装,其中有几次它会根据某些字段 return false。根据哪个失败,我想显示一个输出。我试过:

\Tools::displayError('This worked.');
array_push($this->context->controller->errors, $this->l('This worked.'));

我的安装是这样的:

public function install() {
    \Tools::displayError('This worked.');
    array_push($this->context->controller->errors, $this->l('This worked.'));
    return (parent::install() && false); // Force a fail to test
}

然而,我似乎得到的只是:

Unfortunately, the module did not return additional details.

我已经在 Internet 上查找修复程序,但 have only come across outdated ones。任何帮助将不胜感激。

编辑:我的构造函数将 need_instance 设置为 1:

public function __construct() {
    ...
    $this->need_instance = 1;
    ...
    parent::__construct();
    ...
}

更新:为了帮助未来的观众,Db class 的 insert 功能自动将前缀添加到 table 名称。删除 self::DB_PREFIX 解决了这个问题。

return \Db::getInstance()->insert('iezon_portfolio', array(
    'img_link' => pSQL($img),
    'title' => pSQL($title),
    'description' => pSQL($description),
    'company_name' => pSQL($company),
    'company_url' => pSQL($company_url),
    'testimonial' => pSQL($testimonial),
    'is_favourite' => (int) $fav,
));

尝试这样的事情:

public function install()
{
    if ($this->checkForErrors()) {
        $this->_errors[] = $this->l('Error message');
        return false;
    }

    ...rest of the code...
}