public function testGetParametersBadColumns()
 {
     $this->setExpectedException('PDOException', '', '42S22');
     Hosttemplate::getParameters(1, 'test_error');
     Connector::getParameters(1, array('name', 'test_error'));
 }
示例#2
0
 /**
  * Get the value from template
  *
  * @param int $hostId The host template Id
  * @param bool $isBase If the host template id is the base for get values
  * @return array
  */
 public static function getInheritanceValues($hostId, $isBase = false, $columns = array())
 {
     $values = array();
     $templates = HostRepository::getTemplateChain($hostId, array(), -1);
     if ($isBase) {
         array_unshift($templates, array('id' => $hostId));
     }
     foreach ($templates as $template) {
         if (count($columns) > 0) {
             $inheritanceValues = static::getInheritanceValues($template['id'], false, $columns);
             $tmplValues = Hosttemplate::getParameters($template['id'], $columns);
         } else {
             $inheritanceValues = static::getInheritanceValues($template['id']);
             $tmplValues = Hosttemplate::getParameters($template['id'], self::$inheritanceColumns);
         }
         $tmplValues = array_filter($tmplValues, function ($value) {
             return !is_null($value);
         });
         $tmplValues = array_merge($inheritanceValues, $tmplValues);
         $values = array_merge($tmplValues, $values);
     }
     return $values;
 }