/** * * @throws \Exception */ protected function preInstall() { $newModuleId = Module::getIdByParameter('name', $this->moduleInfo['shortname']); if (count($newModuleId) == 0) { $params = array('name' => $this->moduleInfo['shortname'], 'alias' => $this->moduleInfo['name'], 'description' => $this->moduleInfo['description'], 'author' => implode(", ", $this->moduleInfo['author']), 'name' => $this->moduleInfo['shortname'], 'version' => $this->moduleInfo['version'], 'isactivated' => '0', 'isinstalled' => '0'); Module::insert($params); $newModuleId = Module::getIdByParameter('name', $this->moduleInfo['shortname']); $this->moduleId = $newModuleId[0]; } else { throw new \Exception("Module already installed"); } }
/** * * @param string $version * @param boolean $addDependencies */ public function updateVersionInDb($version, $addDependencies = false) { $dataToInsert = array('version' => $version); // Get Module ID, if exist we update otherwise we insert $moduleId = ModuleModel::getIdByParameter('name', array($this->moduleSlug)); if (count($moduleId) > 0) { ModuleModel::update($moduleId[0], $dataToInsert); } else { if (!is_null($this->moduleInfo)) { $dataToInsert['alias'] = $this->moduleInfo['name']; $dataToInsert['name'] = $this->moduleInfo['shortname']; $moduleId = ModuleModel::insert($dataToInsert); } } if ($addDependencies) { $this->setDependencies($moduleId); } }