定制 ormin/mapping-domain-events-handler 二次开发

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

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

ormin/mapping-domain-events-handler

Composer 安装命令:

composer require ormin/mapping-domain-events-handler

包简介

Set of classes allowing you to grasp the benefits of using and persisting domain events while still persisting state changes into your system

README 文档

README

Allows you to map the domain events to atomic calls, which will persist the desired event's state change. Useful if you're not having/not able to implement Event Sourcing into your system, but you want to make use of Domain Events as a primary source of change within your code

To install it, use Composer:

$ composer require --dev ormin/mapping-domain-events-handler:dev-master

To use it, inject the EventBasedRepository class into your domain repository implementation and pass the AggregateRoot for it to save

class Member implements AggregateRoot { ... }

class DBALMemberRepository implements MemberRepository {

	private $repository;

	public function __construct(EventBasedRepository $repository) {
		$this->repository = $repository;
	}

	public function save(Member $aggregateRoot) {
		$this->repository->save($aggregateRoot);
	}

}


You instantiate one EventBasedRepository per aggregate, with an event store implementation. This project ships with a SimpleMappingEventStore, which will map the events to the POPO objects' calls. Create the POPO handler object, and instantiate SimpleMappingEventStore with it injected as a constructor parameter:

class UserAddedAProductToBasket { ... }

class DBALMappingMemberEventStore {

	public function handleUserAddedAProductToBasket() {
		//Handle persisting of state of what happened within the aggregate
		$statement = $this->connection->prepare("INSERT INTO ...");
	}

}


class User extends EventSourcedAggregateRoot {

	public function addToBasket(Product $product) {
		$this->apply(new UserAddedAProductToBasket($product));
	}

	public function handleUserAddedAProductToBasket(UserAddedAProductToBasket $event) {
		//Handle the event within the aggregate
	}

	//When this aggregate will be sent for saving, its uncommitted events' will be sent to event store and mapped to the DBALMappingMemberEventStore::handleUserAddedAProductToBasket()

}


统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固