kaliop / content-decorator-bundle
Decorate your Ibexa content with custom model classes.
Package info
github.com/kaliop/content-decorator-bundle
Type:symfony-bundle
pkg:composer/kaliop/content-decorator-bundle
Requires
- php: ^8.1
- ibexa/core: ~4.6
- nyholm/psr7: ^1.8
- pagerfanta/pagerfanta: ^2.0
- symfony/cache: ^5.4
- symfony/config: ^5.4
- symfony/dependency-injection: ^5.4
- symfony/event-dispatcher: ^5.4
- symfony/http-kernel: ^5.4
Requires (Dev)
- ibexa/code-style: ~2.2.0
- phpstan/phpstan: ^1.10
- phpstan/phpstan-symfony: ^1.3
- qossmic/deptrac-shim: ^0.24.0 || ^1.0.2
This package is auto-updated.
Last update: 2026-03-11 15:49:02 UTC
README
Kaliop Content Decorator Bundle is an Ibexa extension inspired by
eZObjectWrapperBundle. It lets you work with Ibexa Content objects as
typed models plus dedicated repositories.
Instead of using raw content objects everywhere, you map content types to custom classes extending
Kaliop\Contracts\ContentDecorator\Model\ContentDecorator.
Compatibility
| Bundle line | Ibexa | Symfony | PHP |
|---|---|---|---|
| 1.x | 4.6 | 5.4 LTS | >= 8.1 |
Installation
composer require kaliop/content-decorator-bundle
If Symfony Flex does not enable the bundle automatically, register it in config/bundles.php:
return [ Kaliop\Bundle\ContentDecorator\KaliopContentDecoratorBundle::class => ['all' => true], ];
Quick Start
- Configure mappings:
# config/packages/kaliop_content_decorator.yaml kaliop_content_decorator: default_class: App\Model\GenericContent default_repository_class: Kaliop\ContentDecorator\Repository\ContentRepository mappings: App: namespace: 'App\Model' dir: '%kernel.project_dir%/src/Model'
- Create a decorator class:
<?php declare(strict_types=1); namespace App\Model; use Kaliop\ContentDecorator\Attribute\Decorator; use Kaliop\Contracts\ContentDecorator\Model\ContentDecorator; #[Decorator(repositoryClass: App\Repository\ArticleRepository::class, contentTypes: ['article'])] final class Article extends ContentDecorator { }
- Create a repository:
<?php declare(strict_types=1); namespace App\Repository; use Kaliop\ContentDecorator\Repository\AbstractContentRepository; final class ArticleRepository extends AbstractContentRepository { public function findByAuthorId(int $authorId): array { // Implement query logic return []; } }
- Use
ContentDecoratorManagerin your service/controller:
$repository = $contentDecoratorManager->getRepository(App\Model\Article::class); $articles = $repository->findByAuthorId(42);
Configuration
kaliop_content_decorator: default_class: App\Model\GenericContent default_repository_class: Kaliop\ContentDecorator\Repository\ContentRepository mappings: App: namespace: 'App\Model' dir: '%kernel.project_dir%/src/Model' content_types: article: App\Model\Article
Injectors
Decorators are not Symfony services. Use injectors to add services during decoration. Implement
Kaliop\Contracts\ContentDecorator\Injector\InjectorInterface and tag as kaliop.content_decorator.injector
(autoconfiguration handles this automatically).
Default injectors:
ConfigResolverInjectorIbexaRepositoryInjectorImageVariationInjectorLoggerInjectorManagerInjectorTranslatorInjectorUrlGeneratorInjector
Performance and Method-Level Cache
- Decorated instances are cached in memory per request.
- Proxy classes can cache selected method results.
- Mark methods with
#[Cacheable]. - Method parameters must be serializable.
use Kaliop\ContentDecorator\Attribute\Cacheable; #[Cacheable] public function getExpensiveComputation(): array { return []; }
Contribute
The tool comes with quite a few built-in fixers, but everyone is more than welcome to contribute more of them.
License
This library is released under the MIT license. See the included LICENSE file for more information.