mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°3190 - Edit n:n LinkedSetIndirect in object details using a tagset-like widget
- 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
This commit is contained in:
75
sources/Service/Links/LinkSetModel.php
Normal file
75
sources/Service/Links/LinkSetModel.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user