kaliop/content-decorator-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kaliop/content-decorator-bundle

Composer 安装命令:

composer require kaliop/content-decorator-bundle

包简介

Decorate your Ibexa content with custom model classes.

README 文档

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
2.x 5.0 7.4 LTS >= 8.3

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

  1. 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'
  1. 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
{
}
  1. 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 [];
    }
}
  1. Use ContentDecoratorManager in 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:

  • ConfigResolverInjector
  • IbexaRepositoryInjector
  • ImageVariationInjector
  • LoggerInjector
  • ManagerInjector
  • TranslatorInjector
  • UrlGeneratorInjector

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.

统计信息

  • 总下载量: 431
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固