Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 3
0
 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 "Missing todo id parameter!\n";
     exit(1);
 }
 $todoId = $argv[0];
 try {
     $todoId = TodoId::fromString($todoId);
 } catch (\Exception $ex) {
     echo "Invalid todo id given!\n";
     exit(1);
 }
 /** @var $todoList TodoList */
 $todoList = $container->get(TodoList::class);
 $todo = $todoList->get($todoId);
 if (null === $todo) {
     echo "Todo could not be found!\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);
Ejemplo n.º 4
0
 /**
  * @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));
 }