diff --git a/core/attributedef/AttributeLinkedSetIndirect.php b/core/attributedef/AttributeLinkedSetIndirect.php new file mode 100644 index 000000000..90d838647 --- /dev/null +++ b/core/attributedef/AttributeLinkedSetIndirect.php @@ -0,0 +1,96 @@ +Get('ext_key_to_remote'); + } + + public function GetEditClass() + { + return "LinkedSet"; + } + + public function DuplicatesAllowed() + { + return $this->GetOptional("duplicates", false); + } // The same object may be linked several times... or not... + + public function GetTrackingLevel() + { + return $this->GetOptional('tracking_level', + MetaModel::GetConfig()->Get('tracking_level_linked_set_indirect_default')); + } + + /** + * Find the corresponding "link" attribute on the target class, if any + * + * @return null | AttributeDefinition + * @throws \CoreException + */ + public function GetMirrorLinkAttribute() + { + $oRet = null; + /** @var \AttributeExternalKey $oExtKeyToRemote */ + $oExtKeyToRemote = MetaModel::GetAttributeDef($this->GetLinkedClass(), $this->GetExtKeyToRemote()); + $sRemoteClass = $oExtKeyToRemote->GetTargetClass(); + foreach (MetaModel::ListAttributeDefs($sRemoteClass) as $sRemoteAttCode => $oRemoteAttDef) { + if (!$oRemoteAttDef instanceof AttributeLinkedSetIndirect) { + continue; + } + if ($oRemoteAttDef->GetLinkedClass() != $this->GetLinkedClass()) { + continue; + } + if ($oRemoteAttDef->GetExtKeyToMe() != $this->GetExtKeyToRemote()) { + continue; + } + if ($oRemoteAttDef->GetExtKeyToRemote() != $this->GetExtKeyToMe()) { + continue; + } + $oRet = $oRemoteAttDef; + break; + } + + return $oRet; + } + + /** @inheritDoc */ + public static function IsBulkModifyCompatible(): bool + { + return true; + } + +} \ No newline at end of file