/** * * @cmdObject string module the module name */ public function rollbackAction($object) { $module = $object['module']; InputOutput::display(_("Revert all migrations")); $migrationManager = new Manager($module, 'production'); $cmd = $this->getPhinxCallLine() . 'rollback '; $cmd .= '-c ' . $migrationManager->getPhinxConfigurationFile(); $cmd .= '-e ' . $module; shell_exec($cmd); }
/** * */ public function generateAction() { $moduleCanonicalName = InputOutput::prompt(_("Type the module canonical name here (in CamelCase, it must not contains Module at the ends)"), function ($params, &$result) { call_user_func_array(array('\\Centreon\\Internal\\Module\\Informations', 'isCanonicalNameValid'), array($params, &$result)); }); // Display Name and short name $moduleDisplayName = CamelCaseTransformation::camelCaseToCustom($moduleCanonicalName, " "); $moduleShortname = strtolower(CamelCaseTransformation::camelCaseToCustom($moduleCanonicalName, "-")); $moduleGenerator = new Generator($moduleCanonicalName); $moduleGenerator->setModuleShortName($moduleShortname); $moduleGenerator->setModuleDisplayName($moduleDisplayName); // Get Module ShortName set by user $userAnswer = InputOutput::prompt(_("Type the module shortname here (seperate by -) [" . $moduleShortname . "]")); if (!empty($userAnswer)) { $moduleShortname = $userAnswer; } // Type User Name $moduleAuthor = InputOutput::prompt(_("Type your name here")); $moduleGenerator->setModuleAuthor($moduleAuthor); // Ask For generating Directory Structure InputOutput::display(_("Generating module full structure... "), false); $moduleGenerator->generateModuleStructure(); $moduleGenerator->generateConfigFile(); $moduleGenerator->createSampleInstaller(); InputOutput::display(_("Done\n"), true, "bgreen"); // Ask For sample Controller/View $generateController = InputOutput::prompt(_("Generate sample controller/view (yes/no)? [yes]")); if (empty($generateController) || $generateController == "yes" || $generateController == "y") { $moduleGenerator->createSampleController(); $moduleGenerator->createSampleView(); } // Ask to install the module $installModule = InputOutput::prompt(_("Install the module(yes/no)? [no] ")); if (!empty($installModule) && ($installModule == "yes" || $installModule == "y")) { $moduleInstaller = Informations::getModuleInstaller($moduleShortname); $moduleInstaller->install(); } }
/** * * @param string $object */ public function deleteAction($object) { $repository = $this->repository; $repository::transco($object); $id = ''; $sName = static::renameObject($this->objectName); $aId = $repository::getListBySlugName($object[$sName]); if (count($aId) > 0) { $id = $aId[0]['id']; } else { throw new \Exception(static::OBJ_NOT_EXIST); } $repository::delete(array($id)); \Centreon\Internal\Utils\CommandLine\InputOutput::display("Object successfully deleted", true, 'green'); }
/** * * @param string $message * @param boolean $withEndOfLine */ protected function displayOperationMessage($message, $withEndOfLine = true) { if ($this->launcher == 'console') { InputOutput::display($message, $withEndOfLine); } elseif ($this->launcher == 'web') { } }
/** * */ public function getSlugAction($object = null) { \Centreon\Internal\Utils\CommandLine\InputOutput::display('Not implemented Yet', true, 'red'); }
/** * * @cmdObject string host-name the name of the object * @cmdObject string service-description the name of the object */ public function getSlugAction($object) { $repository = $this->repository; $slug = $repository::getServiceSlugByUniqueField($object['service-description'], $object['host-name']); \Centreon\Internal\Utils\CommandLine\InputOutput::display($slug, true, 'green'); }
/** * * @param string $object * @param string $macro */ public function removeMacroAction($object, $macro) { //try { $repository = $this->repository; //$objectId = $repository::getIdFromUnicity($this->parseObjectParams($object)); $sName = $this->objectName; $repository::transco($object); $aId = $repository::getListBySlugName($object[$sName]); if (count($aId) > 0) { $objectId = $aId[0]['id']; } else { throw new \Exception(static::OBJ_NOT_EXIST, 1); } switch ($this->objectName) { case 'hosttemplate': case 'host': CustomMacroRepository::setAttributesMap(self::$attributesMapHost); CustomMacroRepository::transco($macro); CustomMacroRepository::deleteHostCustomMacro($objectId, $macro); break; case 'servicetemplate': case 'service': CustomMacroRepository::setAttributesMap(self::$attributesMapService); CustomMacroRepository::transco($macro); CustomMacroRepository::deleteServiceCustomMacro($objectId, $macro); break; default: break; } InputOutput::display("The macro '" . $macro . "' has been successfully removed from the object", true, 'green'); /* } catch (\Exception $ex) { InputOutput::display($ex->getMessage(), true, 'red'); }*/ }
/** /** * @cmdObject string poller the poller slug * @cmdParam string action required the action */ public function applyAction($object, $param) { $exit = 1; $id = PollerRepository::getIdBySlugName($object['poller']); if (!is_null($id)) { $action = $param['action']; $obj = new ConfigApplyRepository($id); $obj->action($action); echo $obj->getOutput(); if ($obj->getStatus() === 1) { $exit = 0; } else { $exit = 1; } } else { \Centreon\Internal\Utils\CommandLine\InputOutput::display("Error : Poller not in Database", true, 'red'); $exit = 1; } exit($exit); }
/** * * @cmdObject string $object-name the name of the object */ public function getSlugAction($object) { $repository = $this->repository; $slug = $repository::getSlugByUniqueField($object); \Centreon\Internal\Utils\CommandLine\InputOutput::display($slug, true, 'green'); }
/** * * @param string $object * @param string $tag */ public function removeTagAction($object, $tag) { $iNbDeleted = 0; $sLibTag = "tag"; $repository = $this->repository; $sName = $this->objectName; $repository::transco($object); $aId = $repository::getListBySlugName($object[$sName]); if (count($aId) > 0) { $object = $aId[0]['id']; } else { throw new \Exception(static::OBJ_NOT_EXIST, 1); } $aTags = explode(",", $tag); foreach ($aTags as $sTag) { $iReturn = TagsRepository::isExist($sTag); $bLinked = TagsRepository::isLink($this->objectName, $object, $iReturn); if (!$bLinked) { throw new \Exception("This tag can't be found on the object", 1); } TagsRepository::delete($sTag, $this->objectName, $object); $iNbDeleted++; } if ($iNbDeleted > 1) { $sLibTag .= "s"; } InputOutput::display($sLibTag . " has been successfully removed from the object", true, 'green'); }