johnkhansrc/api-platform-stream-translate-bundle
最新稳定版本:3.2.0
Composer 安装命令:
composer require johnkhansrc/api-platform-stream-translate-bundle
包简介
A lightweight extension allowing to translate in the ApiPlatform flow the values of the properties of an entity by a simple annotation.
README 文档
README
A lightweight extension allowing to translate in the ApiPlatform flow the properties values of an entity by a simple annotation.
Requirements
- symfony/translation >=5.4
- api-platform/core: >=2.5
- doctrine/annotations >=1.0
Instalation
composer require johnkhansrc/api-platform-stream-translate-bundle
Update your services.yaml
# Using annotation Johnkhansrc\ApiPlatformStreamTranslateBundle\EventListener\StreamTranslateAnnotationListener: ~ # Or Using attribute Johnkhansrc\ApiPlatformStreamTranslateBundle\EventListener\StreamTranslateAttributeListener: ~
Usage
Annotation
use Johnkhansrc\ApiPlatformStreamTranslateBundle\Annotation\StreamTranslate; /** * @ApiResource * @ORM\Entity(repositoryClass=AnyEntityRepository::class) */ class AnyEntity { /** * @ORM\Id */ private $id; /** * Expect translation file anyDomain.xx.yaml who contain 'anykey' key * * @StreamTranslate(domain="anyDomain", key="anyKey") */ private string $anyStringPropertyKeyBasedExample; /** * Expect translation file anyDomain.xx.yaml who contain property value as key * * @StreamTranslate(domain="anyDomain") */ private string $anyStringPropertyNoKeyBasedExample; /** * * * NEW ON 2.0.0 * * * * Iterate on each embed relation, don't forget do annotate related class properties. * Tips: You can use different domain on related class property's annotation. * * @StreamTranslate(domain="anyDomain", childs=true) */ private ArrayCollection $anyStringPropertyNoKeyBasedExample; }
Attribute
use Johnkhansrc\ApiPlatformStreamTranslateBundle\Attribute\StreamTranslate; /** * @ApiResource * @ORM\Entity(repositoryClass=AnyEntityRepository::class) */ class AnyEntity { /** * @ORM\Id */ private $id; /** * Expect translation file anyDomain.xx.yaml who contain 'anykey' key */ #[StreamTranslate(domain: "anyDomain", key: "anyKey")] private string $anyStringPropertyKeyBasedExample; /** * Expect translation file anyDomain.xx.yaml who contain property value as key */ #[StreamTranslate(domain: "anyDomain")] private string $anyStringPropertyNoKeyBasedExample; /** * * * NEW ON 2.0.0 * * * * Iterate on each embed relation, don't forget do annotate related class properties. * Tips: You can use different domain on related class property's annotation. */ #[StreamTranslate(domain: "anyDomain", childs: true)] private ArrayCollection $anyStringPropertyNoKeyBasedExample; }
统计信息
- 总下载量: 1.21k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-10