cleverage/eav-api-platform-bundle

针对 Sidus/EAVModelBundle 的 ApiPlatform 依赖项的专用包

dev-v1.0-dev 2020-03-10 13:44 UTC

This package is auto-updated.

Last update: 2024-09-10 23:25:58 UTC


README

此包为 Sidus/EAVModelBundle 与 ApiPlatform 提供基本支持。

当将任何家族声明为 Api 的资源时,您需要为该家族声明一个特定类

SidusEAVModelBundle/Documentation/12-custom_classes.html

并且为了使 Hydra 文档正常工作,您需要使用 @Family 注解注解最终类。

其余部分为基本的 ApiPlatform 实现。

安装

在您的 composer.json 中要求 Api Platform(使用您需要的版本),以及如果您需要公开 EAV 数据,则还需要 EAV 兼容性包

{
    # ...
    "require": {
        # ...
        "api-platform/api-platform": "2.1.*",
        "cleverage/eav-api-platform-bundle": "1.0.*"
    }
}

将包添加到您的内核中

<?php
        $projectBundles = [
            // ...
            new ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle(),
            new CleverAge\EAVApiPlatformBundle\CleverAgeEAVApiPlatformBundle(),
        ];

过滤器

此包提供了 6 个不同的过滤器,您可以使用它们在资源类声明中替代 Doctrine 的 ApiPlatform 的过滤器。

  • CleverAge\EAVApiPlatformBundle\Filter\BooleanFilter
  • CleverAge\EAVApiPlatformBundle\Filter\DateFilter
  • CleverAge\EAVApiPlatformBundle\Filter\NumericFilter
  • CleverAge\EAVApiPlatformBundle\Filter\OrderFilter
  • CleverAge\EAVApiPlatformBundle\Filter\RangeFilter
  • CleverAge\EAVApiPlatformBundle\Filter\SearchFilter