定制 rtxlabs/data-transformation-bundle 二次开发

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

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

rtxlabs/data-transformation-bundle

Composer 安装命令:

composer require rtxlabs/data-transformation-bundle

包简介

README 文档

README

Symfony2 Bundle that can help building REST services.

Example

Providing a REST service that returns a list of contacts linked with companies. The service has to deliver something like that:

[{
    "id": 1181,
    "address": null,
    "email": "max.mustermann@dtb.com",
    "firstname": "Max",
    "lastname": "Mustermann",
    "company": 7
} , {
    "id" : 1177,
    "address" : null,
    "email" : "uwe.klawitter@dtb.com",
    "firstname" : "Uwe",
    "lastname" : "Klawitter",
    "company": 298
}]

To generate this, some Doctrine entities have to be loaded from a repository and converted into json. Performing an json_encode() to on the entities won't work, because the entity contains proxy objects to the company. To solve this, the DoctrineBinder can be used:

// loading the entity manager to create the doctrine binder instance
$em = $this->getDoctrine()->getEntityManager();

// create a doctrine binder, bind the models that have been loaded before and execute the binder. The execute
// method will iterate over the models and return an array containing stdClass objects with all values defined
// by getters.
$result = DoctrineBinder::create($em)->bind($models)->execute();

// finally the result has to be converted into json to return it as an response
$json = Dencoder::decode($result);

Documentation

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-11-18