dtn55928 2017-02-04 13:01
浏览 21
已采纳

Prestashop模块关闭

I'm creating my first blog for prestashop so far I'm getting to do what I wanted, so I came to a problem that I can not solve:

The module needs an api key to work, the issue is that I can give a warning if this api key does not exist, what I can not do is to disconnect the module, so I use it to understand that something is missing.

if (!Configuration::get('API_KEY')){
    $this->warning = $this->l('No api key provided');
}else{
    $this->_apiKey = Configuration::get('API_KEY');
}

I wanted to turn off the module if there is no variable. So that after the hook he does not execute the code.

  • 写回答

1条回答 默认 最新

  • duanpuchen3142 2017-02-04 15:29
    关注

    In any hook you can begin with:

    if(!($this->_apiKey = Configuration::get('API_KEY')))
        return false;
    

    If there is no API_KEY in configuration it will not execute the rest of the code. EDIT: You can disable it using in the hook.

    if(!($this->_apiKey = Configuration::get('API_KEY')))
    {
            $this->disable(false);  // true to disable for all shops
            return false;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题