-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IBX-8434: Added ProviderConfiguratorInterface to allow configuration …
…post-processing
- Loading branch information
Showing
9 changed files
with
158 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/contracts/Configuration/ProviderConfiguratorInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\Contracts\FieldTypeRichText\Configuration; | ||
|
||
interface ProviderConfiguratorInterface | ||
{ | ||
/** | ||
* @param array<string, mixed> $configuration | ||
* | ||
* @return array<string, mixed> | ||
*/ | ||
public function getConfiguration(array $configuration): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\FieldTypeRichText\Configuration\Provider; | ||
|
||
use Ibexa\Contracts\FieldTypeRichText\Configuration\Provider; | ||
|
||
final class ConfigurableProvider implements Provider | ||
{ | ||
private Provider $inner; | ||
|
||
/** @var iterable<\Ibexa\Contracts\FieldTypeRichText\Configuration\ProviderConfiguratorInterface> */ | ||
private iterable $configurators; | ||
|
||
/** | ||
* @param iterable<\Ibexa\Contracts\FieldTypeRichText\Configuration\ProviderConfiguratorInterface> $configurators | ||
*/ | ||
public function __construct( | ||
Provider $inner, | ||
iterable $configurators | ||
) { | ||
$this->inner = $inner; | ||
$this->configurators = $configurators; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->inner->getName(); | ||
} | ||
|
||
/** | ||
* @return array<string, mixed> | ||
*/ | ||
public function getConfiguration(): array | ||
{ | ||
$configuration = $this->inner->getConfiguration(); | ||
foreach ($this->configurators as $configurator) { | ||
$configuration = $configurator->getConfiguration($configuration); | ||
} | ||
|
||
return $configuration; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.