mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°9065 - XML Definition for Dashlet properties
This commit is contained in:
@@ -9,6 +9,9 @@ namespace Combodo\iTop\Forms\IO;
|
||||
|
||||
use Combodo\iTop\Forms\Block\AbstractFormBlock;
|
||||
use Combodo\iTop\Forms\IO\Format\AbstractIOFormat;
|
||||
use Combodo\iTop\Forms\IO\Format\AttributeIOFormat;
|
||||
use Combodo\iTop\Forms\IO\Format\ClassIOFormat;
|
||||
use Combodo\iTop\Forms\IO\Format\StringIOFormat;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
|
||||
/**
|
||||
@@ -312,4 +315,26 @@ class AbstractFormIO
|
||||
return $this->aBindingsToInputs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compatibility rules
|
||||
*
|
||||
* @param \Combodo\iTop\Forms\IO\AbstractFormIO $oFormIO
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsCompatibleWith(AbstractFormIO $oFormIO): bool
|
||||
{
|
||||
if ($this->GetDataType() === StringIOFormat::class) {
|
||||
switch ($oFormIO->GetDataType()) {
|
||||
case StringIOFormat::class:
|
||||
case AttributeIOFormat::class:
|
||||
case ClassIOFormat::class:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return ($oFormIO->GetDataType() === $this->GetDataType());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class FormBinding
|
||||
// Check IOFormat validity
|
||||
$sSourceDataType = $oSourceIO->GetDataType();
|
||||
$sDestinationDataType = $oDestinationIO->GetDataType();
|
||||
if ($sSourceDataType !== $sDestinationDataType) {
|
||||
if (!$oDestinationIO->IsCompatibleWith($oSourceIO)) {
|
||||
throw new FormBlockIOException('binding '.json_encode($sSourceDataType).' to '.json_encode($sDestinationDataType).' is not supported');
|
||||
}
|
||||
$this->oDestinationIO = $oDestinationIO;
|
||||
|
||||
Reference in New Issue
Block a user