fightmaster/dao
Composer 安装命令:
composer require fightmaster/dao
包简介
Simple implementation of Data Access Object pattern for Symfony 2 projects.
关键字:
README 文档
README
Simple implementation of Data Access Object pattern for symfony 2 projects.
- Has unit tests: yes
- Vendors: doctrine-common
Advantages
- allows you to quickly switch between the ORM and ODM doctrine managers
- promote clean and tested code. all of the business application logic should be in the services
Installation
If you use a deps file, you could add:
[dao]
git=https://github.com/fightmaster/dao.git
Or if you want to clone the repos:
git clone https://github.com/fightmaster/dao.git vendor/dao
If you use Composer, you could add:
{"require": {"fightmaster/dao": "1.x"}}
Add the namespace to your autoloader
<?php $loader->registerNamespaces(array( ............ 'Fightmaster' => __DIR__.'/../vendor/dao/src', ........... ));
Examples
Example service layer
<?php ..... Class ProductService extends Service { public function __construct(ManagerInterface $manager) { $this->manager = $manager; } .... public function saveProduct(Product $product) { $prePersistEvent = new PrePersistEvent($product); $this->dispatcher->dispatch('product_pre_persist', $prePersistEvent); if (!$prePersistEvent->isAborted()) { $this->manager->save($product); } $postPersistEvent = new PostPersistEvent($product); $this->dispatcher->dispatch('product_post_persist', $postPersistEvent); } public function changeProductName(Product $product, $newName) { .... $product->setName($newName); $this->saveProduct($product); } }
统计信息
- 总下载量: 144
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-07-08