Project

General

Profile

Bug #93962 ยป form.issue-93962.patch

Hannes Bochmann, 2024-06-05 11:34

View differences:

Classes/Domain/Finishers/AbstractFinisher.php
$this->options = $options;
}
public function getOptions(): array
{
return $this->options;
}
/**
* Sets a single finisher option (@see setOptions())
*
Classes/Domain/Finishers/FinisherInterface.php
public function execute(FinisherContext $finisherContext);
public function setFinisherIdentifier(string $finisherIdentifier): void;
public function getFinisherIdentifier(): string;
/**
* @param array $options configuration options in the format ['option1' => 'value1', 'option2' => 'value2', ...]
*/
public function setOptions(array $options);
public function getOptions(): array;
/**
* Sets a single finisher option (@see setOptions())
*
Classes/Domain/Model/FormDefinition.php
if (isset($options['finishers'])) {
if ($resetFinishers) {
$this->finishers = [];
}
foreach ($options['finishers'] as $finisherConfiguration) {
$this->createFinisher($finisherConfiguration['identifier'], $finisherConfiguration['options'] ?? []);
} elseif (is_array($options['finishers'])) {
$this->mergeOrCreateFinishers($options['finishers']);
}
}
......
*/
public function addFinisher(FinisherInterface $finisher)
{
$this->finishers[] = $finisher;
$this->finishers[$finisher->getFinisherIdentifier()] = $finisher;
}
/**
* Merge given finishers with existing finisher options or create new finishers.
*
* @param list<array{identifier?: string, options?: array<string, mixed>}> $finishers
* @internal
*/
protected function mergeOrCreateFinishers(array $finishers): void
{
foreach ($finishers as $finisherConfiguration) {
$finisher = $this->finishers[$finisherConfiguration['identifier']] ?? null;
if ($finisher !== null) {
$finisherOptions = $finisher->getOptions();
ArrayUtility::mergeRecursiveWithOverrule($finisherOptions, $finisherConfiguration['options'] ?? []);
$finisher->setOptions($finisherOptions);
} else {
$this->createFinisher($finisherConfiguration['identifier'], $finisherConfiguration['options'] ?? []);
}
}
}
/**
Classes/Domain/Model/Renderable/RenderableVariant.php
*/
public function apply(): void
{
$this->renderable->setOptions($this->options, true);
$this->renderable->setOptions($this->options);
$this->applied = true;
}
    (1-1/1)