/** * @return TodoId */ public function todoId() { if (is_null($this->todoId)) { $this->todoId = TodoId::fromString($this->aggregateId()); } return $this->todoId; }
/** * @return UserId */ public function todoId() { if (!$this->todoId) { $this->todoId = TodoId::fromString($this->payload['todo_id']); } return $this->todoId; }
function get_todo_version(Todo $todo) { $todoReflected = new \ReflectionClass($todo); $versionProp = $todoReflected->getProperty('version'); $versionProp->setAccessible(true); return $versionProp->getValue($todo); } $container = (require 'config/container.php'); array_shift($argv); if (empty($argv)) { echo "[1;31mMissing todo id parameter![0m\n"; exit(1); } $todoId = $argv[0]; try { $todoId = TodoId::fromString($todoId); } catch (\Exception $ex) { echo "[1;31mInvalid todo id given![0m\n"; exit(1); } /** @var $todoList TodoList */ $todoList = $container->get(TodoList::class); $todo = $todoList->get($todoId); if (null === $todo) { echo "[1;31mTodo could not be found![0m\n"; exit(1); } /** @var $snapshotStore SnapshotStore */ $snapshotStore = $container->get(SnapshotStore::class); $snapshot = new Snapshot(AggregateType::fromAggregateRoot($todo), $todoId->toString(), $todo, get_todo_version($todo), new \DateTimeImmutable("now", new \DateTimeZone('UTC'))); $snapshotStore->save($snapshot);
/** * @return TodoId */ public function todoId() { return TodoId::fromString($this->payload['todo_id']); }
<?php /** * This script looks for todos with open reminders and reminds the assignees */ namespace { use Prooph\ProophessorDo\Model\Todo\Command\RemindTodoAssignee; use Prooph\ProophessorDo\Model\Todo\TodoId; use Prooph\ProophessorDo\Model\Todo\TodoReminder; use Prooph\ProophessorDo\Projection\Todo\TodoReminderFinder; use Prooph\ServiceBus\CommandBus; chdir(dirname(__DIR__)); // Setup autoloading require 'vendor/autoload.php'; $container = (require 'config/container.php'); $commandBus = $container->get(CommandBus::class); $todoReminderFinder = $container->get(TodoReminderFinder::class); $todoReminder = $todoReminderFinder->findOpen(); if (!$todoReminder) { echo "Nothing to do. Exiting.\n"; exit; } foreach ($todoReminder as $reminder) { echo "Send reminder for Todo with id {$reminder->todo_id}.\n"; $commandBus->dispatch(RemindTodoAssignee::forTodo(TodoId::fromString($reminder->todo_id), TodoReminder::fromString($reminder->reminder, $reminder->status))); } echo "Done!\n"; }
public function getEvent($todoId) { return TodoWasMarkedAsExpired::fromStatus(TodoId::fromString($todoId), TodoStatus::fromString(TodoStatus::OPEN), TodoStatus::fromString(TodoStatus::EXPIRED)); }