bestit/commercetools-odm-bundle
Composer 安装命令:
composer require bestit/commercetools-odm-bundle
包简介
Makes the commercetools database accessible with the doctrine commons api.
README 文档
README
Makes the commercetools database accessible with the doctrine commons api. It still uses the commmercetools/php-sdk under the hood.
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require bestit/commercetools-odm-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new BestIt\CommercetoolsODMBundle\BestItCommercetoolsODMBundle(), ); // ... } // ... }
Step 3: Configure the Bundle
# Default configuration for "BestItCommercetoolsODMBundle"
bestit_commercetools_odm:
# Please provide the service id for your commercetools client.
client_service_id: ~ # Required
# Please provide the service id for your commercetools request async pool.
pool_service_id: ~
This bundle ships a client factory which you can use to create a client. Example:
services:
Commercetools\Core\Client:
factory: 'BestIt\CommercetoolsODMBundle\Factory\ClientFactory:create'
arguments:
- {client_id: '%env(COMMERCETOOLS_CLIENT_ID)%', client_secret: '%env(COMMERCETOOLS_CLIENT_SECRET)%', project: '%env(COMMERCETOOLS_PROJECT)%', scope: ['manage_project'] }
- {locale: 'de', languages: ['de'] }
BestIt\CommercetoolsODMBundle\Factory\ClientFactory:
class: BestIt\CommercetoolsODMBundle\Factory\ClientFactory
arguments: ['@cache.app', '@logger']
Usage
Event Listener with the sercice container
You can add an event listener to the typical live cycle events if you tag your service with the name best_it_commercetools_odm.event_listener. But don't forget the name of the event with the key event on your tag.
Example:
# app/config/services.yml services: app.tokens.action_listener: class: AppBundle\EventListener\TokenListener arguments: ['%tokens%'] tags: - { name: best_it_commercetools_odm.event_listener, event: postPersist }
the method of the service should match the event name.
Services
The service best_it.commercetools_odm.manager provices you with an extended Doctrine\Common\Persistence\ObjectManager.
the method of the service should match the event name.
Filters
You can add multiple filters to apply on requests. Just create one filter, implement the FilterInterface and tag the service with best_it_commercetools_odm.filter. The filter get the raw created request and will be applied just before the request will be send.
Example:
// ProductFilter.php class ProductFilter implements FilterInterface { /** * {@inheritdoc} */ public function getKey() { return 'product'; } /** * {@inheritdoc} */ public function apply($request) { $request->setExpands(['masterVariant.attributes[*].value', 'productType', 'categories[*].ancestors[*]']); $request->channel('xyz'); $request->currency('EUR'); } }
# app/config/services.yml services: app.filter.product_filter: class: AppBundle\Filter\ProductFilter tags: - { name: best_it_commercetools_odm.filter }
Now you can apply the one or more filter whenever you want:
app.repository.product_projection: class: BestIt\CommercetoolsODM\Model\ProductProjectionRepository factory: ["@best_it.commercetools_odm.manager", getRepository] arguments: - Commercetools\Core\Model\Product\ProductProjection calls: - [filter, ['projection', 'projection-categories']]
bestit/commercetools-odm-bundle 适用场景与选型建议
bestit/commercetools-odm-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23.89k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 04 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bestit/commercetools-odm-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bestit/commercetools-odm-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 23.89k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-04-16