示例#1
0
 public function getValues($inherited = false)
 {
     $values = array();
     $c = new Criteria();
     $c->add(NagiosServiceTemplateInheritancePeer::SOURCE_SERVICE, $this->getId());
     $c->addAscendingOrderByColumn(NagiosServiceTemplateInheritancePeer::ORDER);
     $inheritanceTemplates = NagiosServiceTemplateInheritancePeer::doSelect($c);
     if (count($inheritanceTemplates)) {
         // This template has inherited templates, let's bring their values in
         foreach ($inheritanceTemplates as $inheritanceItem) {
             $serviceTemplate = $inheritanceItem->getNagiosServiceTemplateRelatedByTargetTemplate();
             $templateValues = $serviceTemplate->getValues(true);
             $values = array_merge($values, $templateValues);
         }
     }
     foreach (NagiosServicePeer::getFieldNames() as $fieldName) {
         $colName = NagiosServicePeer::translateFieldName($fieldName, BasePeer::TYPE_PHPNAME, BasePeer::TYPE_COLNAME);
         // At this point, $fieldName is the fieldname for each column in our table record
         $colName = strtolower(substr($colName, strlen("nagios_service.")));
         // $colName is now the abbreviated column name.
         switch ($colName) {
             case 'maximum_check_attempts':
                 $colName = 'max_check_attempts';
                 break;
         }
         $methodName = "get" . $fieldName;
         if (method_exists($this, $methodName)) {
             $val = $this->{$methodName}();
             if ($val !== null) {
                 // Yay, let's populate
                 $values[$colName] = array('inherited' => $inherited, 'source' => array('id' => $this->getId(), 'name' => $this->getDescription()), 'value' => $val);
             }
         }
     }
     return $values;
 }
示例#2
0
 /**
  * Sets a field from the object by name passed in as a string.
  *
  * @param      string $name peer name
  * @param      mixed $value field value
  * @param      string $type The type of fieldname the $name is of:
  *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
  *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
  * @return     void
  */
 public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
 {
     $pos = NagiosServicePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
     return $this->setByPosition($pos, $value);
 }