定制 johnkhansrc/api-platform-stream-translate-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-12-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固