/** * @param array $parameters */ public function replay($parameters = []) { $criteria = Criteria::create(); if (isset($parameters['types'])) { $criteria = $criteria->withEventTypes($parameters['types']); } if (isset($parameters['id'])) { $criteria = $criteria->withAggregateRootIds($parameters['id']); } $visitor = new CallableEventVisitor(function ($event) { $this->addEvent($event); }); $this->eventManager->visitEvents($criteria, $visitor); $this->publishEvents(); }
/** * @test * @expectedException \Broadway\EventStore\Management\CriteriaNotSupportedException */ public function it_visits_aggregate_root_types() { $visitedEvents = $this->visitEvents(Criteria::create()->withAggregateRootTypes(array('Broadway.EventStore.Management.AggregateTypeOne', 'Broadway.EventStore.Management.AggregateTypeTwo'))); }
private function prepareVisitEventsStatementWhereAndBindValues(Criteria $criteria) { if ($criteria->getAggregateRootTypes()) { throw new CriteriaNotSupportedException('DBAL implementation cannot support criteria based on aggregate root types.'); } $bindValues = array(); $bindValueTypes = array(); $criteriaTypes = array(); if ($criteria->getAggregateRootIds()) { $criteriaTypes[] = 'uuid IN (:uuids)'; if ($this->useBinary) { $bindValues['uuids'] = array(); foreach ($criteria->getAggregateRootIds() as $id) { $bindValues['uuids'][] = $this->convertIdentifierToStorageValue($id); } $bindValueTypes['uuids'] = Connection::PARAM_STR_ARRAY; } else { $bindValues['uuids'] = $criteria->getAggregateRootIds(); $bindValueTypes['uuids'] = Connection::PARAM_STR_ARRAY; } } if ($criteria->getEventTypes()) { $criteriaTypes[] = 'type IN (:types)'; $bindValues['types'] = $criteria->getEventTypes(); $bindValueTypes['types'] = Connection::PARAM_STR_ARRAY; } if (!$criteriaTypes) { return array('', array(), array()); } $where = 'WHERE ' . join(' AND ', $criteriaTypes); return array($where, $bindValues, $bindValueTypes); }