-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Respect ContainerInterface in StandardVariableProvider (#1002)
With this change, it is possible to access properties of objects implementing `Psr\Container\ContainerInterface` from Fluid templates using the normal object accessor syntax. The interface requires two methods `has()` and `get()` which are used by Fluid to obtain the requested property from the object.
- Loading branch information
Showing
4 changed files
with
102 additions
and
1 deletion.
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
30 changes: 30 additions & 0 deletions
30
tests/Unit/Core/Variables/Fixtures/StandardVariableProviderContainerFixture.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,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file belongs to the package "TYPO3 Fluid". | ||
* See LICENSE.txt that was shipped with this package. | ||
*/ | ||
|
||
namespace TYPO3Fluid\Fluid\Tests\Unit\Core\Variables\Fixtures; | ||
|
||
use Psr\Container\ContainerInterface; | ||
|
||
/** | ||
* Used by StandardVariableProviderTest | ||
*/ | ||
final readonly class StandardVariableProviderContainerFixture implements ContainerInterface | ||
{ | ||
public function __construct(private array $properties) {} | ||
|
||
public function get(string $id): mixed | ||
{ | ||
return $this->properties[$id] ?? null; | ||
} | ||
|
||
public function has(string $id): bool | ||
{ | ||
return array_key_exists($id, $this->properties); | ||
} | ||
} |
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