mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°2363 - API : deprecate old linkedset update pattern
This commit is contained in:
@@ -131,10 +131,6 @@ class LoginWebPage extends NiceWebPage
|
||||
//add profiles not already linked with user
|
||||
foreach ($aProfiles as $iProfileId)
|
||||
{
|
||||
$oLink = new URP_UserProfile();
|
||||
$oLink->Set('profileid', $iProfileId);
|
||||
$oLink->Set('reason', $sOrigin);
|
||||
|
||||
$oProfilesSet->AddItem(MetaModel::NewObject('URP_UserProfile', array('profileid' => $iProfileId, 'reason' => $sOrigin)));
|
||||
}
|
||||
$oUser->Set('profile_list', $oProfilesSet);
|
||||
|
||||
@@ -358,7 +358,10 @@ class WizardHelper
|
||||
{$sWizardHelperJsVar}.UpdateFields();
|
||||
JS;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function with an old pattern of code
|
||||
* @deprecated since 3.1
|
||||
*/
|
||||
static function ParseJsonSet($oMe, $sLinkClass, $sExtKeyToMe, $sJsonSet)
|
||||
{
|
||||
$aSet = json_decode($sJsonSet, true); // true means hash array instead of object
|
||||
|
||||
@@ -5209,45 +5209,34 @@ abstract class DBObject implements iDisplay
|
||||
if ($sSourceAttCode == 'id')
|
||||
{
|
||||
$oSourceAttDef = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!MetaModel::IsValidAttCode(get_class($this), $sDestAttCode))
|
||||
{
|
||||
} else {
|
||||
if (!MetaModel::IsValidAttCode(get_class($this), $sDestAttCode)) {
|
||||
throw new Exception("Unknown attribute ".get_class($this)."::".$sDestAttCode);
|
||||
}
|
||||
if (!MetaModel::IsValidAttCode(get_class($oSourceObject), $sSourceAttCode))
|
||||
{
|
||||
if (!MetaModel::IsValidAttCode(get_class($oSourceObject), $sSourceAttCode)) {
|
||||
throw new Exception("Unknown attribute ".get_class($oSourceObject)."::".$sSourceAttCode);
|
||||
}
|
||||
|
||||
$oSourceAttDef = MetaModel::GetAttributeDef(get_class($oSourceObject), $sSourceAttCode);
|
||||
}
|
||||
if (is_object($oSourceAttDef) && $oSourceAttDef->IsLinkSet())
|
||||
{
|
||||
if (is_object($oSourceAttDef) && $oSourceAttDef->IsLinkSet()) {
|
||||
// The copy requires that we create a new object set (the semantic of DBObject::Set is unclear about link sets)
|
||||
/** @var \AttributeLinkedSet $oSourceAttDef */
|
||||
$oDestSet = DBObjectSet::FromScratch($oSourceAttDef->GetLinkedClass());
|
||||
$oDestSet = $this->Get($sDestAttCode);
|
||||
$oSourceSet = $oSourceObject->Get($sSourceAttCode);
|
||||
$oSourceSet->Rewind();
|
||||
/** @var \DBObject $oSourceLink */
|
||||
while ($oSourceLink = $oSourceSet->Fetch())
|
||||
{
|
||||
while ($oSourceLink = $oSourceSet->Fetch()) {
|
||||
// Clone the link
|
||||
$sLinkClass = get_class($oSourceLink);
|
||||
$oLinkClone = MetaModel::NewObject($sLinkClass);
|
||||
foreach(MetaModel::ListAttributeDefs($sLinkClass) as $sAttCode => $oAttDef)
|
||||
{
|
||||
foreach (MetaModel::ListAttributeDefs($sLinkClass) as $sAttCode => $oAttDef) {
|
||||
// As of now, ignore other attribute (do not attempt to recurse!)
|
||||
if ($oAttDef->IsScalar() && $oAttDef->IsWritable())
|
||||
{
|
||||
if ($oAttDef->IsScalar() && $oAttDef->IsWritable()) {
|
||||
$oLinkClone->Set($sAttCode, $oSourceLink->Get($sAttCode));
|
||||
}
|
||||
}
|
||||
|
||||
// Not necessary - this will be handled by DBObject
|
||||
// $oLinkClone->Set($oSourceAttDef->GetExtKeyToMe(), 0);
|
||||
$oDestSet->AddObject($oLinkClone);
|
||||
$oDestSet->AddItem($oLinkClone);
|
||||
}
|
||||
$this->Set($sDestAttCode, $oDestSet);
|
||||
}
|
||||
|
||||
@@ -153,8 +153,7 @@ class ormLinkSet implements iDBObjectSetIterator, Iterator, SeekableIterator
|
||||
*/
|
||||
public function AddObject(DBObject $oObject, $sClassAlias = '')
|
||||
{
|
||||
// cannot notify depreciation for now as this is still MASSIVELY used in iTop core !
|
||||
//DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use \ormLinkSet::AddItem() instead');
|
||||
DeprecatedCallsLog::NotifyDeprecatedPhpMethod('use \ormLinkSet::AddItem() instead');
|
||||
$this->AddItem($oObject);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user