mirror of
https://github.com/Combodo/iTop.git
synced 2026-03-06 01:24:15 +01:00
- Add generic set block ui component - Add model link set (direct and indirect) attribute (display style) - Add model link set direct allowed values - Create link set viewer block UI (BlockLinksSetDisplayAsProperty) - Add set block ui factory for linkset - Add object factory and create new endpoint in object controller (with data binder) - Add link set model, link set repository and link set data transformer services
75 lines
1.5 KiB
PHP
75 lines
1.5 KiB
PHP
<?php
|
|
/*
|
|
* @copyright Copyright (C) 2010-2022 Combodo SARL
|
|
* @license http://opensource.org/licenses/AGPL-3.0
|
|
*/
|
|
|
|
namespace Combodo\iTop\Service\Links;
|
|
|
|
use AttributeExternalKey;
|
|
use AttributeLinkedSet;
|
|
use AttributeLinkedSetIndirect;
|
|
use Exception;
|
|
use MetaModel;
|
|
|
|
/**
|
|
* Class LinkSetModel
|
|
*
|
|
* @internal
|
|
* @since 3.1.0
|
|
* @package Combodo\iTop\Service\Links
|
|
*/
|
|
class LinkSetModel
|
|
{
|
|
/**
|
|
* GetTargetClass.
|
|
*
|
|
* @param AttributeLinkedSet $oAttDef
|
|
*
|
|
* @return string
|
|
*/
|
|
static public function GetTargetClass(AttributeLinkedSet $oAttDef): string
|
|
{
|
|
try {
|
|
if ($oAttDef instanceof AttributeLinkedSetIndirect) {
|
|
/** @var AttributeExternalKey $oLinkingAttDef */
|
|
$oLinkingAttDef = MetaModel::GetAttributeDef($oAttDef->GetLinkedClass(), $oAttDef->GetExtKeyToRemote());
|
|
|
|
return $oLinkingAttDef->GetTargetClass();
|
|
} else {
|
|
return $oAttDef->GetLinkedClass();
|
|
}
|
|
}
|
|
catch (Exception $e) {
|
|
return 'unknown';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* GetLinkedClass.
|
|
*
|
|
* @param AttributeLinkedSet $oAttDef
|
|
*
|
|
* @return string
|
|
*/
|
|
static public function GetLinkedClass(AttributeLinkedSet $oAttDef): string
|
|
{
|
|
return $oAttDef->GetLinkedClass();
|
|
}
|
|
|
|
/**
|
|
* GetTargetField.
|
|
*
|
|
* @param AttributeLinkedSet $oAttDef
|
|
*
|
|
* @return string|null
|
|
*/
|
|
static public function GetTargetField(AttributeLinkedSet $oAttDef): ?string
|
|
{
|
|
if ($oAttDef instanceof AttributeLinkedSetIndirect) {
|
|
return $oAttDef->GetExtKeyToRemote();
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
} |