示例#1
0
 /**
  * 
  * @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');
        }*/
 }