Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Allow AttributeSet in XML sample file #654

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions setup/xmldataloader.class.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,27 @@ function LoadFile($sFilePath, $bUpdateKeyCacheOnly = false, bool $bSearch = fals
$oDoc = new ormDocument($data, $sMimeType, $sFileName);
$oTargetObj->Set($sAttCode, $oDoc);
}
elseif ($oAttDef instanceof AttributeTagSet)
elseif ($oAttDef instanceof AttributeSet)
{
// TODO
$value = (string)$oSubNode;

if ($value == '')
{
$value = $oAttDef->GetNullValue();
}
else
{
$value = $oAttDef->MakeRealValue($value, $oTargetObj);
}
$res = $oTargetObj->CheckValue($sAttCode, $value);
if ($res !== true)
{
// $res contains the error description
$sMsg = "Value not allowed - $sClass/$iSrcId - $sAttCode: '".$oSubNode."' ; $res";
SetupLog::Error($sMsg);
$this->m_aErrors[] = $sMsg;
}
$oTargetObj->Set($sAttCode, $value);
}
else
{
Expand Down
12 changes: 12 additions & 0 deletions tests/php-unit-tests/unitary-tests/core/XMLDataLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ public function testDataLoader()
<obsolescence_flag>no</obsolescence_flag>
<obsolescence_date></obsolescence_date>
</Person>
<TriggerOnObjectUpdate alias="TriggerOnObjectUpdate" id="4">
<description>Contact updated</description>
<action_list></action_list>
<context>GUI:Console</context>
<complement>class restriction: Contact</complement>
<subscription_policy>allow_no_channel</subscription_policy>
<target_class>Contact</target_class>
<filter>SELECT `Person` FROM Person AS `Person` WHERE ((`status` = &apos;active&apos;) AND ((`org_id` = :current_contact-&gt;org_id) OR (`org_id` = :this-&gt;org_id)))</filter>
<target_attcodes>email</target_attcodes>
<finalclass>TriggerOnObjectUpdate</finalclass>
<friendlyname>Contact updated</friendlyname>
</TriggerOnObjectUpdate>
</Set>
XML;
$this->CreateFromXMLString($sXML);
Expand Down