N°8771 - Add Symfony form component to iTop core

- IO debug
This commit is contained in:
Benjamin Dalsass
2025-10-28 15:22:29 +01:00
parent c2fcf4144b
commit 5d335b39d2
36 changed files with 1348 additions and 468 deletions

View File

@@ -10,27 +10,59 @@ use Combodo\iTop\Forms\Block\FormBlockIOException;
class FormInput extends AbstractFormIO
{
private FormBinding|null $oBinding = null;
private array $aBindingsToInputs = [];
public function Bind(AbstractFormIO $oSourceIO): void
/**
* @throws FormBlockIOException
*/
public function BindFromOutput(FormOutput $oSourceIO): void
{
if($this->GetType() !== $oSourceIO->GetType()){
if($this->GetDataType() !== $oSourceIO->GetDataType()){
throw new FormBlockIOException('Cannot connect input types incompatibles ' . $this->GetName() . ' from ' . $oSourceIO->GetOwnerBlock()->GetName() . ' ' . $oSourceIO->GetName());
}
$this->oBinding = new FormBinding($this, $oSourceIO);
$this->oBinding = $oSourceIO->BindToInput($this);
}
public function GetBinding(): FormBinding
/**
* @throws FormBlockIOException
*/
public function BindFromInput(FormInput $oSourceIO): void
{
if($this->GetDataType() !== $oSourceIO->GetDataType()){
throw new FormBlockIOException('Cannot connect input types incompatibles ' . $this->GetName() . ' from ' . $oSourceIO->GetOwnerBlock()->GetName() . ' ' . $oSourceIO->GetName());
}
$this->oBinding = $oSourceIO->BindToInput($this);
}
/**
* @throws FormBlockIOException
*/
public function BindToInput(FormInput $oDestinationIO): FormBinding
{
if($this->GetDataType() !== $oDestinationIO->GetDataType()){
throw new FormBlockIOException('Cannot connect input types incompatibles ' . $this->GetName() . ' from ' . $oDestinationIO->GetOwnerBlock()->GetName() . ' ' . $oDestinationIO->GetName());
}
$oBinding = new FormBinding($this, $oDestinationIO);
$this->aBindingsToInputs[] = $oBinding;
return $oBinding;
}
public function GetBinding(): ?FormBinding
{
return $this->oBinding;
}
public function IsDataReady(string $sEventType): bool
public function IsDataReady(): bool
{
return $this->oBinding->oSourceIO->HasValue($sEventType);
return $this->HasValue();
}
public function IsBound(): bool
@@ -38,4 +70,25 @@ class FormInput extends AbstractFormIO
return $this->oBinding !== null;
}
public function SetValues(array $aValues): AbstractFormIO
{
parent::SetValues($aValues);
$this->PropagateBindingsValues();
return $this;
}
/**
* Propagate the bindings values.
*
* @return void
*/
public function PropagateBindingsValues(): void
{
// propagate the value
foreach ($this->aBindingsToInputs as $oBinding) {
$oBinding->PropagateValues();
}
}
}