-
Notifications
You must be signed in to change notification settings - Fork 2
PhpCode as a new Transformer #1463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.x
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new PhpCode transformer system that allows developers to create custom PHP-based transformers for grid column values. The implementation uses Symfony's tagged service pattern to enable pluggable transformation logic.
Key changes:
- Adds a new
PhpCodetransformer with a resolver pattern for discovering and executing tagged PHP transformer services - Provides an example transformer (
ExamplePhpCodeTransformer) that converts strings to uppercase - Updates configuration and documentation to support the new transformer type
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
src/Grid/Column/Transformer/PhpCode/TaggedPhpCodeTransformerResolver.php |
Implements the resolver to locate transformer services by class name using Symfony's TaggedIterator |
src/Grid/Column/Transformer/PhpCode/PhpCodeTransformerResolverInterface.php |
Defines the contract for resolving PhpCode transformers with service tag constant |
src/Grid/Column/Transformer/PhpCode/PhpCodeTransformerInterface.php |
Defines the contract that custom PHP transformers must implement |
src/Grid/Column/Transformer/PhpCode/ExamplePhpCodeTransformer.php |
Provides a demonstration transformer that converts string values to uppercase |
src/Grid/Column/Transformer/PhpCode.php |
Main transformer class that delegates to tagged services based on configuration |
doc/03_Grid.md |
Adds documentation for the PhpCode transformer with usage examples |
config/grid.yaml |
Registers the PhpCode transformer and example transformer as tagged services |
src/Grid/Column/Transformer/PhpCode/PhpCodeTransformerInterface.php
Outdated
Show resolved
Hide resolved
src/Grid/Column/Transformer/PhpCode/PhpCodeTransformerInterface.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor changes.
And the API Endpoint for listing the Tagged Services is still missing.
src/Grid/Column/Transformer/PhpCode/PhpCodeTransformerInterface.php
Outdated
Show resolved
Hide resolved
src/Grid/Column/Transformer/PhpCode/TaggedPhpCodeTransformerResolver.php
Outdated
Show resolved
Hide resolved
src/Grid/Service/Loader/TaggedIteratorPhpCodeTransformerLoader.php
Outdated
Show resolved
Hide resolved
src/Grid/Service/Loader/TaggedIteratorPhpCodeTransformerLoader.php
Outdated
Show resolved
Hide resolved
| } | ||
| } | ||
|
|
||
| throw new InvalidArgumentException( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the NotFoundException
https://github.com/pimcore/studio-backend-bundle/blob/1.x/src/Exception/Api/NotFoundException.php
|
|
||
| foreach ($this->resolver->getTransformers() as $executable) { | ||
| $options[] = [ | ||
| 'value' => get_class($executable), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and we do not need to return the class_name only the key and name
doc/03_Grid.md
Outdated
| #### PhpCode Transformer | ||
|
|
||
| The `PhpCode` transformer delegates value transformation to a custom PHP class implementing the Pimcore\Bundle\StudioBackendBundle\Grid\Column\PhpCodeTransformerInterface. This allows developers to encapsulate complex transformation logic in reusable services. | ||
| To register a transformer, the service must be tagged with the appropriate Symfony service tag (e.g. studio_backend.grid.php_code_transformer) so it can be discovered by the system. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| To register a transformer, the service must be tagged with the appropriate Symfony service tag (e.g. studio_backend.grid.php_code_transformer) so it can be discovered by the system. | |
| To register a transformer, the service must be tagged with the appropriate Symfony service tag (studio_backend.grid.php_code_transformer) so it can be discovered by the system. |
| /** | ||
| * @internal | ||
| */ | ||
| final class PhpCodeTransformerCollectionException extends AbstractApiException |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this used?
|



Changes in this pull request
Resolves #1155
Additional info