GetHostClass(); } $aMappingData = $this->GetMapRule($sClass); if ($aMappingData == null) { $aRet = []; } else { $aRet = [$aMappingData['attcode']]; } return $aRet; } /** * Overload the standard so as to leave the data unsorted * * @param array $aArgs * @param string $sContains * * @return array|null */ public function GetAllowedValues($aArgs = [], $sContains = '') { $oValSetDef = $this->GetValuesDef(); if (!$oValSetDef) { return null; } $aRawValues = $oValSetDef->GetValueList(); if (is_null($aRawValues)) { return null; } $aLocalizedValues = []; foreach ($aRawValues as $sKey => $sValue) { $aLocalizedValues[$sKey] = $this->GetValueLabel($sKey); } return $aLocalizedValues; } /** * Returns the meta value for the given object. * See also MetaModel::RebuildMetaEnums() that must be maintained when MapValue changes * * @param $oObject * * @return mixed * @throws Exception */ public function MapValue($oObject) { $aMappingData = $this->GetMapRule(get_class($oObject)); if ($aMappingData == null) { $sRet = $this->GetDefaultValue(); } else { $sAttCode = $aMappingData['attcode']; $value = $oObject->Get($sAttCode); if (array_key_exists($value, $aMappingData['values'])) { $sRet = $aMappingData['values'][$value]; } elseif ($this->GetDefaultValue() != '') { $sRet = $this->GetDefaultValue(); } else { throw new Exception('AttributeMetaEnum::MapValue(): mapping not found for value "'.$value.'" in '.get_class($oObject).', on attribute '.MetaModel::GetAttributeOrigin( $this->GetHostClass(), $this->GetCode() ).'::'.$this->GetCode()); } } return $sRet; } public function GetMapRule($sClass) { $aMappings = $this->Get('mapping'); if (array_key_exists($sClass, $aMappings)) { $aMappingData = $aMappings[$sClass]; } else { $sParent = MetaModel::GetParentClass($sClass); if (is_null($sParent)) { $aMappingData = null; } else { $aMappingData = $this->GetMapRule($sParent); } } return $aMappingData; } }