mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
N°8771 - Add Symfony form component to iTop core
- IO debug
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user