Skip to content

Add ImageFilter serializer attribute with repeatable keys#11

Merged
wtorsi merged 8 commits intomainfrom
8.0
Mar 24, 2026
Merged

Add ImageFilter serializer attribute with repeatable keys#11
wtorsi merged 8 commits intomainfrom
8.0

Conversation

@baldrys-ed
Copy link
Copy Markdown
Contributor

@baldrys-ed baldrys-ed commented Mar 23, 2026

Summary

  • Add #[ImageFilter] attribute and ImageFilterAttributeNormalizer for automatic image URL generation in API responses (serializer counterpart to existing Twig macros)
  • Attribute is repeatable with a key parameter — multiple attributes on one property produce a keyed map of avif/webp × 1x/2x/3x HMAC-signed URLs
  • Fix env placeholder resolution in post-processor binary validation
  • Fix interface_exists check for conditional normalizer registration
  • Add chamber-orchestra/view-bundle as dev dependency for integration testing
  • Output formats: avif and webp only (no original format)

Test plan

  • Unit tests for ImageFilter attribute (defaults, custom values, repeatability, multiple keys)
  • Unit tests for ImageFilterAttributeNormalizer (supports check, null/empty/non-image handling, delegation to fill/fit/optimize, leading slash stripping, preset passthrough, cache behavior)
  • Integration tests with TestKernel + Symfony serializer chain (service registration, single/multiple attributes, null files, plain objects, HMAC-signed URLs)
  • Extension tests for env placeholder resolution in binary validation
  • Full suite: 373 tests, 813 assertions passing
  • CS-fixer clean

🤖 Generated with Claude Code

dev and others added 5 commits March 23, 2026 12:04
Ports the #[ImageFilter] attribute and normalizer from alabuga into the bundle.
Generates avif/webp/src × 1x/2x/3x HMAC-signed URLs in API responses,
mirroring the Twig image macro output structure.

- ImageFilter attribute: filter, width, height, preset params
- ImageFilterAttributeNormalizer: reflection-based, with per-class cache,
  null URI guard, setAccessible for private properties
- Registered conditionally via class_exists(NormalizerInterface::class)
- Serializer/ excluded from services glob to prevent unconditional load
- symfony/serializer added to suggest + require-dev
…ace_exists fix

- Make #[ImageFilter] attribute repeatable with a `key` parameter (default: "default")
  so multiple filter configurations on a single property produce a keyed map
- Remove original-format (src) output — normalizer now only generates avif and webp
- Fix conditional registration: use interface_exists instead of class_exists for NormalizerInterface
- Add view-bundle dev dependency for integration testing
- Add unit tests for ImageFilter attribute and ImageFilterAttributeNormalizer
- Add integration tests with TestKernel verifying full serializer chain

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wtorsi wtorsi changed the title [8.0] Add ImageFilterAttributeNormalizer for API serialization Add ImageFilter serializer attribute with repeatable keys Mar 23, 2026
Dev and others added 3 commits March 24, 2026 08:41
…density

Serializer:
- Add ImageFilterMetadataFactory with 3-layer caching (in-memory, PSR-6, reflection)
- Dev-mode cache keys fingerprinted from class/parent/trait file mtimes (recursive)
- Refactor normalizer to use metadata factory instead of direct reflection
- Respect IGNORED_ATTRIBUTES and ATTRIBUTES context (flat and nested/associative)
- Nested ATTRIBUTES prune the output tree (e.g. coverArt.default.avif.1x)
- Configurable output formats via chamber_orchestra_image.serializer.formats
- Validate formats against ImageFormat enum at container build time
- Default densities now [1, 2, 3, 4]

Security:
- StreamLoader: detect both scheme:// and compact scheme: URI forms
- StreamLoader: bare paths treated as implicit "file" scheme, checked against allowlist
- Density upper bound capped at 4.0x in AbstractResizeProcessor
- Post-processor timeouts capped at 300s (pngquant, mozjpeg, cwebp, avifenc)
- PngquantPostProcessor: clamp quality range values to 0-100

Bug fixes:
- CacheManager: normalize signing config to processors+output only
- RuntimeAction: include output in URL query params and signature verification
- Remove deprecated setAccessible() call (no-op since PHP 8.1)
- Fix PHPUnit with() without expects() deprecations

Tests: 399 tests, 942 assertions, zero issues

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… type

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wtorsi wtorsi merged commit 9b89110 into main Mar 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants