Customization: added a check against reuse of an attribute code (collision can happen easily with inheritance)

SVN:trunk[1518]
This commit is contained in:
Romain Quetiez
2011-08-25 16:10:57 +00:00
parent 6df6e4a9cc
commit 2ee85dd407

View File

@@ -1536,11 +1536,22 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass]))
public static function Init_AddAttribute(AttributeDefinition $oAtt)
{
$sAttCode = $oAtt->GetCode();
if ($sAttCode == 'finalclass') throw new Exception('Using a reserved keyword in metamodel declaration: '.$sAttCode);
if ($sAttCode == 'friendlyname') throw new Exception('Using a reserved keyword in metamodel declaration: '.$sAttCode);
$sTargetClass = self::GetCallersPHPClass("Init");
$sAttCode = $oAtt->GetCode();
if ($sAttCode == 'finalclass')
{
throw new Exception("Declaration of $sTargetClass: using the reserved keyword '$sAttCode' in attribute declaration");
}
if ($sAttCode == 'friendlyname')
{
throw new Exception("Declaration of $sTargetClass: using the reserved keyword '$sAttCode' in attribute declaration");
}
if (array_key_exists($sAttCode, self::$m_aAttribDefs[$sTargetClass]))
{
throw new Exception("Declaration of $sTargetClass: attempting to redeclare the inherited attribute '$sAttCode', originaly declared in ".self::$m_aAttribOrigins[$sTargetClass][$sAttCode]);
}
// Set the "host class" as soon as possible, since HierarchicalKeys use it for their 'target class' as well
// and this needs to be know early (for Init_IsKnowClass 19 lines below)
$oAtt->SetHostClass($sTargetClass);