swoopster/objectmanagerbundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

swoopster/objectmanagerbundle

Composer 安装命令:

composer require swoopster/objectmanagerbundle

包简介

Bundle provides structured model handling

关键字:

README 文档

README

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 swoopster/objectmanagerbundle "~0.2"

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 the following line in the app/AppKernel.php file of your project:

<?php
// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {

        $bundles = array(
            new Swoopster\ObjectManagerBundle\SwoopsterObjectManagerBundle()
        );
    
    }

}

Step 3: Configure Bundle

Define coniguration parameters to customize bundle for your own needs. You need to define which bundles should be managed by the ObjectManager. Currently this bundle supports only the xml-mapping-format.

swoopster_object_manager:
    model_dir: Model #default
    mapping_format: xml #default
    bundles:
        - {namespace: Swoopster\TestBundle}

#Usage

Define Mappings

Define your mapping definitions inside BundleFolder/Resources/config/doctrine/model. Currently only xml mappings supported!

Use Manager

To get the manager use $container->get('id') or use the factory. To use the factory the manager service has to be tagged with the following tag:

<tag name="swoopster.object_manager"/>

Now you can get an Manager by using the $conatainer->get('swoopster.object_manager.manager_factory')->getManager($instanceOfManagedObject)

Standard Manager

To use a manager for an object without customization, define a service like below

<services>
    <service id="swoopster_test.model.test_object_manager" parent="swoopster.object_manager.doctrine_manager">
        <argument>Swoopster\TestBundle\Model\TestModel</argument>
    </service>
</services>

Customizable Manager

To extend the standardmanager define a manager class which extends from Swoopster\ObjectManagerBundle\Doctrine\DoctrineManager and register this class as a service. see example below

<services>
    <service id="swoopster_test.model.test_object_manager" class="Swoopster\TestBundle\Model\TestObjectManager" parent="swoopster.object_manager.doctrine_manager">
        <argument>Swoopster\TestBundle\Model\TestModel</argument>
    </service>
</services>

Manager Functions

Create

Get a new instance of managed modelclass

$manager->create()

Save

save or update an instance of managed modelclass. Second argument defines if orm should persist object immediately or later, default is true (immediately).

$manager->save($object, $flush)

Delete

delete an existing instance of managed modelclass

$manager->delete($object, $flush)

Find

the manager supports a predefined set of methods to find objects in database. you can find supported functions in Swoopster\ObjectManagerBundle\Model\ManagerInterface

$manager->find*()

Lifecycle Events

To use the lifecycle events you need to comply with the following requirments

  1. the model to be managed must implement Swoopster\ObjectManagerBundle\Model\EventDrivenModelInterface
  2. the manager belonging to this model must implement Swoopster\ObjectManagerBundle\Model\ManagerEventInterface
  3. manager must be registered in the factory

Supported Events

All events are expecting an instance of the managed model as argument

  • prePersist
  • postPersit
  • preUpdate
  • postUpdate
  • preRemove
  • postRemove
  • postLoad

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

swoopster/objectmanagerbundle 适用场景与选型建议

swoopster/objectmanagerbundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 12 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「object manager」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 swoopster/objectmanagerbundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 swoopster/objectmanagerbundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 swoopster/objectmanagerbundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-01