Skip to content

Conversation

@stunnerparas
Copy link
Contributor

@stunnerparas stunnerparas commented Oct 20, 2025

Changes in this pull request

Resolves #1155

Additional info

Copy link

Copilot AI left a 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 PhpCode transformer 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

@martineiber martineiber added this to the next milestone Oct 20, 2025
@pimcore pimcore deleted a comment from Copilot AI Oct 20, 2025
@pimcore pimcore deleted a comment from Copilot AI Oct 20, 2025
Copy link
Contributor

@martineiber martineiber left a 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.

@martineiber martineiber modified the milestones: 0.10.21, next Oct 21, 2025
}
}

throw new InvalidArgumentException(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


foreach ($this->resolver->getTransformers() as $executable) {
$options[] = [
'value' => get_class($executable),
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this used?

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Grid] [Advanced Columns] Add Transformers

2 participants