/** * @param RemoveDojoCommand $command */ public function handle(RemoveDojoCommand $command) { $dojo = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->find($command->getId()); $this->doctrine->remove($dojo); $this->doctrine->flush(); $event = new DojoRemovedEvent($command->getId()); $this->eventRecorder->record($event); }
/** * {@inheritdoc} */ public function commit(EventStream $eventStream) { /** @var Message $envelope */ foreach ($eventStream as $envelope) { $this->messageRecorder->record($envelope); } $this->next->commit($eventStream); }
/** * @param CreateDojoCommand $command */ public function handle(CreateDojoCommand $command) { $internalDojo = new Dojo($command->getZenId(), $command->getName(), $command->getCity(), $command->getLat(), $command->getLon(), $command->getEmail(), $command->getWebsite(), $command->getTwitter()); $internalDojo->setZenCreatorEmail($command->getZenCreatorEmail()); $internalDojo->setZenUrl($command->getZenUrl()); $this->doctrine->persist($internalDojo); $event = new DojoCreatedEvent($command->getZenId(), $command->getZenCreatorEmail(), $command->getZenUrl(), $command->getName(), $command->getCity(), $command->getLat(), $command->getLon(), $command->getEmail(), $command->getWebsite(), $command->getTwitter(), $command->isRemoved()); $this->eventRecorder->record($event); }
/** * @param Message $command */ public function handle(Message $command) { // TODO: implement DoctrineUserRepository /** @var User $user */ //$user = $this->userRepository->createUser($command->username, $command->password); //$this->userRepository->insert($user); // create the event //$event = new UserWasRegisteredEvent($user->getUsername()); $userWasRegisteredEvent = new UserWasRegisteredEvent('username'); $this->recordsMessages->record($userWasRegisteredEvent); // create new event to be handle asynchronously $eventId = 11111; $isHandleAsynchronouslySampleEvent = new IsHandleAsynchronouslySampleEvent($eventId); $this->recordsMessages->record($isHandleAsynchronouslySampleEvent); }
/** * @param CreateEventCommand $command */ public function handle(CreateEventCommand $command) { $dojo = $this->doctrine->getRepository('CoderDojoWebsiteBundle:Dojo')->find($command->getDojoId()); $event = new DojoEvent(); $event->setName($command->getName()); $event->setDate($command->getDate()); $event->setType($command->getType()); $event->setZenId($command->getZenId()); $event->setUrl($command->getUrl()); $event->setDojo($dojo); $dojo->addEvent($event); $this->doctrine->persist($event); $this->doctrine->flush(); $event = new EventCreatedEvent($command->getDojoId(), $command->getName(), $command->getDate(), $command->getUrl(), $command->getZenId(), $command->getType()); $this->eventRecorder->record($event); }
/** * Update the search and request objects * * @param $command */ public function handle(SaveSearchRequestCommand $command) { $search = $this->searchRepository->findByQuery($command->queryString()); if (!$search) { // Create a new search object $search = new Search(); $search->setQuery($command->queryString()); } $search->increase(); // Create the new search request $searchRequest = new Request(); $searchRequest->setSearch($search); // Save the changes to the database $this->searchRepository->save($search); $this->requestRepository->save($searchRequest); // Raise the SearchRequestWasPosted event $event = new SearchRequestWasPosted($searchRequest); $this->eventRecorder->record($event); }
/** * @param SubscriptionCancelCommand $message * * @throws \Baboon\SubscriptionBundle\Exception\PackageNotFoundException * @throws \Baboon\SubscriptionBundle\Exception\SubscriptionManageException */ public function cancelSubscription(SubscriptionCancelCommand $message) { if (null === ($package = $this->packageManager->findInitial())) { throw new PackageNotFoundException('Initial package'); } $currentPackage = $this->subscriptionProvider->getPackage(); if (null !== $currentPackage && $currentPackage->isInitial()) { throw new SubscriptionManageException(sprintf('Current package "%s" not cancelable', $currentPackage)); } if (null !== ($subscription = $this->subscriptionProvider->getSubscription())) { $subscription->select($package); $this->subscriptionManager->updateSubscription($subscription); $this->eventRecorder->record(new SubscriptionCanceledEvent($subscription)); } }