-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add reopen todo #59
Merged
Merged
add reopen todo #59
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/* | ||
* This file is part of prooph/proophessor. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 2/16/16 | ||
*/ | ||
namespace Prooph\ProophessorDo\Container\Model\Todo; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use Prooph\ProophessorDo\Model\Todo\Handler\ReopenTodoHandler; | ||
use Prooph\ProophessorDo\Model\Todo\TodoList; | ||
|
||
/** | ||
* Class ReopenTodoFactory | ||
* | ||
* @package Application\Infrastructure\HandlerFactory | ||
* @author Bas Kamer <[email protected]> | ||
*/ | ||
final class ReopenTodoHandlerFactory | ||
{ | ||
/** | ||
* @param ContainerInterface $container | ||
* @return ReopenTodoHandlerFactory | ||
*/ | ||
public function __invoke(ContainerInterface $container) | ||
{ | ||
return new ReopenTodoHandler( | ||
$container->get(TodoList::class) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
/* | ||
* This file is part of prooph/proophessor. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 2/16/16 | ||
*/ | ||
namespace Prooph\ProophessorDo\Model\Todo\Command; | ||
|
||
use Prooph\Common\Messaging\Command; | ||
use Prooph\Common\Messaging\PayloadConstructable; | ||
use Prooph\Common\Messaging\PayloadTrait; | ||
use Prooph\ProophessorDo\Model\Todo\TodoId; | ||
|
||
/** | ||
* Class ReopenTodo | ||
* | ||
* @package Prooph\ProophessorDo\Model\Todo | ||
* @author Bas Kamer <[email protected]> | ||
*/ | ||
final class ReopenTodo extends Command implements PayloadConstructable | ||
{ | ||
use PayloadTrait; | ||
|
||
/** | ||
* | ||
* @param TodoId $todoId | ||
* @return ReopenTodo | ||
*/ | ||
public static function forTodo($todoId) | ||
{ | ||
return new self([ | ||
'todo_id' => (string) $todoId, | ||
]); | ||
} | ||
|
||
/** | ||
* @return TodoId | ||
*/ | ||
public function todoId() | ||
{ | ||
return TodoId::fromString($this->payload['todo_id']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
/* | ||
* This file is part of prooph/proophessor. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 2/16/16 | ||
*/ | ||
namespace Prooph\ProophessorDo\Model\Todo\Event; | ||
|
||
use Prooph\EventSourcing\AggregateChanged; | ||
use Prooph\ProophessorDo\Model\Todo\TodoId; | ||
use Prooph\ProophessorDo\Model\Todo\TodoStatus; | ||
|
||
/** | ||
* Class TodoWasReopened | ||
* | ||
* @package Prooph\ProophessorDo\Model\Todo\Event | ||
* @author Bas Kamer <[email protected]> | ||
*/ | ||
final class TodoWasReopened extends AggregateChanged | ||
{ | ||
private $todoId; | ||
|
||
private $status; | ||
|
||
/** | ||
* @param TodoId $todoId | ||
* @param TodoStatus $status | ||
* @return TodoWasMarkedAsDone | ||
*/ | ||
public static function withStatus(TodoId $todoId, TodoStatus $status) | ||
{ | ||
$event = self::occur($todoId->toString(), [ | ||
'status' => $status->toString() | ||
]); | ||
|
||
$event->todoId = $todoId; | ||
$event->status = $status; | ||
|
||
return $event; | ||
} | ||
|
||
/** | ||
* @return TodoId | ||
*/ | ||
public function todoId() | ||
{ | ||
if (null === $this->todoId) { | ||
$this->todoId = TodoId::fromString($this->aggregateId()); | ||
} | ||
return $this->todoId; | ||
} | ||
|
||
/** | ||
* @return TodoStatus | ||
*/ | ||
public function status() | ||
{ | ||
if (null === $this->status) { | ||
$this->status = TodoStatus::fromString($this->payload['status']); | ||
} | ||
return $this->status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/* | ||
* This file is part of prooph/proophessor. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 2/16/16 | ||
*/ | ||
namespace Prooph\ProophessorDo\Model\Todo\Exception; | ||
|
||
use Prooph\ProophessorDo\Model\Todo\Todo; | ||
use Prooph\ProophessorDo\Model\Todo\TodoStatus; | ||
|
||
/** | ||
* Class CannotReopenTodo | ||
* | ||
* @package Prooph\ProophessorDo\Model\Todo\Exception | ||
* @author Bas Kamer <[email protected]> | ||
*/ | ||
final class CannotReopenTodo extends \RuntimeException | ||
{ | ||
/** | ||
* @param TodoStatus $status | ||
* @param Todo $todo | ||
* @return CannotReopenTodo | ||
*/ | ||
public static function notMarkedDone(Todo $todo) | ||
{ | ||
return new self(sprintf( | ||
'Tried to reopen status of Todo %s. But Todo is not marked as done!', | ||
$todo->todoId()->toString() | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/* | ||
* This file is part of prooph/proophessor. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 2/16/16 | ||
*/ | ||
namespace Prooph\ProophessorDo\Model\Todo\Exception; | ||
|
||
use Prooph\ProophessorDo\Model\Todo\TodoId; | ||
|
||
/** | ||
* Class TodoNotFound | ||
* | ||
* @package Prooph\ProophessorDo\Model\Todo | ||
* @author Bas Kamer <[email protected]> | ||
*/ | ||
final class TodoNotFound extends \InvalidArgumentException | ||
{ | ||
/** | ||
* @param TodoId $todoId | ||
* @return TodoNotFound | ||
*/ | ||
public static function withTodoId(TodoId $todoId) | ||
{ | ||
return new self(sprintf('Todo with id %s cannot be found.', $todoId->toString())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/* | ||
* This file is part of prooph/proophessor. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 2/16/16 | ||
*/ | ||
namespace Prooph\ProophessorDo\Model\Todo\Handler; | ||
|
||
use Prooph\ProophessorDo\Model\Todo\Command\ReopenTodo; | ||
use Prooph\ProophessorDo\Model\Todo\Exception\TodoNotFound; | ||
use Prooph\ProophessorDo\Model\Todo\TodoList; | ||
|
||
/** | ||
* Class ReopenTodoHandler | ||
* | ||
* @package Prooph\ProophessorDo\Model\Todo | ||
* @author Bas Kamer <[email protected]> | ||
*/ | ||
final class ReopenTodoHandler | ||
{ | ||
/** | ||
* @var TodoList | ||
*/ | ||
private $todoList; | ||
|
||
/** | ||
* @param TodoList $todoList | ||
*/ | ||
public function __construct(TodoList $todoList) | ||
{ | ||
$this->todoList = $todoList; | ||
} | ||
|
||
/** | ||
* @param ReopenTodo $command | ||
*/ | ||
public function __invoke(ReopenTodo $command) | ||
{ | ||
$todo = $this->todoList->get($command->todoId()); | ||
if (! $todo) { | ||
throw TodoNotFound::withTodoId($command->todoId()); | ||
} | ||
|
||
$todo->reopenTodo(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check if todo was found, elso throw TodoNotFound