php-arsenal/salesforce-mapper-bundle
Composer 安装命令:
composer require php-arsenal/salesforce-mapper-bundle
包简介
Symfony bundle that maps raw Salesforce objects with your models.
README 文档
README
Introduction
The Symfony bundle helps you fetch & map Salesforce objects effectivelly to your own modals to use later with Doctrine or stand-alone.
Installation
composer require php-arsenal/salesforce-mapper-bundle
Features
- Easily fetch records from Salesforce, and save these same records back to Salesforce: read-only fields are automatically ignored when saving.
- Find by criteria just like in Doctrine.
- Fetch related records in one go, so you save on API calls.
- Adjust the mappings to retrieve and save records exactly like you want to.
- The MappedBulkSaver helps you stay within your Salesforce API limits by using bulk creates, deletes, updates and upserts for mapped objects.
- Completely unit tested (still working on that one).
Usage
Once installed, the bundle offers several services that are autowired for dependancy injection:
- a mapper:
PhpArsenal\SalesforceMapperBundle\Mapper - a bulk saver:
PhpArsenal\SalesforceMapperBundle\MappedBulkSaver
Fetch filtered records
Use the mapper to fetch records from Salesforce. An example:
<?php use PhpArsenal\SalesforceMapperBundle\Mapper; use PhpArsenal\SalesforceMapperBundle\Model\Opportunity; class MyService { private $mapper; public function __construct(Mapper $mapper) { $fetchedObjects = $mapper->findBy(new Opportunity(), [ 'Name' => 'Just an opportunity', ]); } }
You can even fetch related records just by going through related objects:
... $opportunity = $fetchedObjects[0]; echo 'The opportunity belongs to: ' . $opportunity->getAccount()->getName(); ...
Fetch all records
... $fetchedObjects = $mapper->findAll(Opportunity::class); ...
Saving records
If you create a new record and save it, the ID assigned to it by Salesforce is
accessible with getId().
... $opportunity = new Opportunity(); $opportunity->setName('Some name'); echo $opportunity->getId(); // Returns null $mapper->save($account); echo $account->getId(); // Returns the new ID, e.g. `001D000000h0Jod` ...
PhpArsenal\SalesforceMapperBundle\MappedBulkSaver can be used to save mulitple objects in batches.
Custom objects and properties
In the Model folder you will find several standard Salesforce objects. As this
is a generic client bundle, this directory does not contain custom objects, nor
do the objects in it have custom properties.
If you would like to add custom objects or properties, please extend from AbstractModel or the models provided.
The mapper knows how to map fields reading the annotations above the property:
... use PhpArsenal\SalesforceMapperBundle\Annotation as Salesforce; ... /** * @var string * @Salesforce\Field(name="AccountId") */ protected $accountId; ...
php-arsenal/salesforce-mapper-bundle 适用场景与选型建议
php-arsenal/salesforce-mapper-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.06k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2021 年 04 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 php-arsenal/salesforce-mapper-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 php-arsenal/salesforce-mapper-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8.06k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-04-09