Example #1
0
 /**
  * Hydrate value
  *
  * @param string $name
  * @param string $value
  * @return mixed
  */
 public function hydrateValue($name, $value)
 {
     switch ($name) {
         case 'Name':
             // One-way correction of characters improperly encoded by old agents
             $value = $this->_nameFilter->filter($value);
             break;
         case 'InstallLocation':
             if ($value == 'N/A') {
                 // One-way removal of pseudo-values
                 $value = null;
             } else {
                 // One-way transformation of forward slashes to more common backslashes
                 $value = str_replace('/', '\\', $value);
             }
             break;
         case 'IsHotfix':
             // 0: Windows hotfix, 1: regular software
             $value = !(bool) $value;
             break;
         case 'InstallationDate':
             $value = $value ? new \DateTime($value) : null;
             break;
         case 'Architecture':
             // One-way removal of pseudo-values
             if ($value == '0') {
                 $value = null;
             }
             break;
     }
     return $value;
 }
 /**
  * Hydrate value
  *
  * @param string $name
  * @param string $value
  * @return mixed
  */
 public function hydrateValue($name, $value)
 {
     switch ($name) {
         case 'InventoryDate':
         case 'LastContactDate':
             $value = \DateTime::createFromFormat('Y-m-d H:i:s', $value, $this->_utcTimeZone);
             break;
         case 'OsName':
             $value = $this->_encodingFilter->filter($value);
             break;
     }
     return $value;
 }
Example #3
0
 /**
  * Hydrate value
  *
  * @param string $name
  * @param string $value
  * @return mixed
  */
 public function hydrateValue($name, $value)
 {
     if (isset($this->_extractorMap[$name])) {
         switch ($name) {
             case 'InventoryDate':
             case 'LastContactDate':
                 $value = \DateTime::createFromFormat($this->_serviceLocator->get('Database\\Nada')->timestampFormatPhp(), $value, $this->_databaseTimeZone);
                 break;
             case 'OsName':
                 $value = $this->_encodingFilter->filter($value);
                 break;
         }
     } elseif ($name == 'Package.Status') {
         return $value;
     } elseif (preg_match('/^([a-zA-Z]+)\\.(.+)/', $name, $matches)) {
         $model = $matches[1];
         $property = $matches[2];
         switch ($model) {
             case 'CustomFields':
                 $hydrator = $this->_serviceLocator->get('Model\\Client\\CustomFieldManager')->getHydrator();
                 $value = $hydrator->hydrateValue($property, $value);
                 break;
             case 'Windows':
                 $hydrator = $this->_serviceLocator->get('Database\\Table\\WindowsInstallations')->getHydrator();
                 $value = $hydrator->hydrateValue($property, $value);
                 break;
             case 'Registry':
                 break;
             default:
                 $table = $this->_serviceLocator->get('Model\\Client\\ItemManager')->getTable($model);
                 $hydrator = $table->getHydrator();
                 $value = $hydrator->hydrateValue($property, $value);
         }
     }
     return $value;
 }