diff --git a/sources/Forms/Block/AbstractFormBlock.php b/sources/Forms/Block/AbstractFormBlock.php index a6e4f860d..826602ed1 100644 --- a/sources/Forms/Block/AbstractFormBlock.php +++ b/sources/Forms/Block/AbstractFormBlock.php @@ -134,8 +134,7 @@ abstract class AbstractFormBlock */ public function AddInput(string $sName, string $sType): void { - $oFormInput = new FormInput($sName, $sType); - $oFormInput->SetOwnerBlock($this); + $oFormInput = new FormInput($sName, $sType, $this); $this->aFormInputs[$oFormInput->GetName()] = $oFormInput; } @@ -167,8 +166,7 @@ abstract class AbstractFormBlock */ public function AddOutput(string $sName, string $sType, AbstractConverter $oConverter = null): void { - $oFormOutput = new FormOutput($sName, $sType, $oConverter); - $oFormOutput->SetOwnerBlock($this); + $oFormOutput = new FormOutput($sName, $sType, $this, $oConverter); $this->aFormOutputs[$oFormOutput->GetName()] = $oFormOutput; } diff --git a/sources/Forms/Block/IO/AbstractFormIO.php b/sources/Forms/Block/IO/AbstractFormIO.php index ab678082d..4ffbf0932 100644 --- a/sources/Forms/Block/IO/AbstractFormIO.php +++ b/sources/Forms/Block/IO/AbstractFormIO.php @@ -38,10 +38,11 @@ class AbstractFormIO * @param string $sName name of the IO * @param string $sType type of the IO */ - public function __construct(string $sName, string $sType) + public function __construct(string $sName, string $sType, AbstractFormBlock $oOwnerBlock) { $this->sName = $sName; $this->sType = $sType; + $this->oOwnerBlock = $oOwnerBlock; } /** @@ -54,20 +55,6 @@ class AbstractFormIO return $this->oOwnerBlock; } - /** - * Set the owner block. - * - * @param AbstractFormBlock $oOwnerBlock - * - * @return $this - */ - public function SetOwnerBlock(AbstractFormBlock $oOwnerBlock): self - { - $this->oOwnerBlock = $oOwnerBlock; - - return $this; - } - /** * Get the IO name. * diff --git a/sources/Forms/Block/IO/FormOutput.php b/sources/Forms/Block/IO/FormOutput.php index 29ca940ad..55cd68508 100644 --- a/sources/Forms/Block/IO/FormOutput.php +++ b/sources/Forms/Block/IO/FormOutput.php @@ -6,6 +6,7 @@ namespace Combodo\iTop\Forms\Block\IO; +use Combodo\iTop\Forms\Block\AbstractFormBlock; use Combodo\iTop\Forms\Block\IO\Converter\AbstractConverter; /** @@ -27,9 +28,9 @@ class FormOutput extends AbstractFormIO * @param string $sType * @param AbstractConverter|null $oConverter */ - public function __construct(string $sName, string $sType, AbstractConverter $oConverter = null) + public function __construct(string $sName, string $sType, AbstractFormBlock $oOwnerBlock, AbstractConverter $oConverter = null) { - parent::__construct($sName, $sType); + parent::__construct($sName, $sType, $oOwnerBlock); $this->oConverter = $oConverter; } diff --git a/sources/Forms/FormBuilder/DependencyMap.php b/sources/Forms/FormBuilder/DependencyMap.php index 57b0f0f5d..88c05deac 100644 --- a/sources/Forms/FormBuilder/DependencyMap.php +++ b/sources/Forms/FormBuilder/DependencyMap.php @@ -121,6 +121,19 @@ class DependencyMap return $aResult; } + public function GetImpacted(string $sBlockName): array + { + $aImpacted = []; + foreach ($this->aOutputToInputsMap[$sBlockName] as $aBindings) { + foreach ($aBindings as $oBinding) { + $oDestBlock = $oBinding->oDestinationIO->GetOwnerBlock(); + $aImpacted[] = $oDestBlock; + } + } + + return $aImpacted; + } + /** * @param string $sBlockName * diff --git a/tests/php-unit-tests/unitary-tests/sources/Forms/Block/IO/AbstractFormIOTest.php b/tests/php-unit-tests/unitary-tests/sources/Forms/Block/IO/AbstractFormIOTest.php new file mode 100644 index 000000000..90c8ef381 --- /dev/null +++ b/tests/php-unit-tests/unitary-tests/sources/Forms/Block/IO/AbstractFormIOTest.php @@ -0,0 +1,15 @@ +