Slide 82
Slide 82 text
82
class BackLogApplicationService
{
/** @var Transaction */
private $transaction;
/** @var UserContextInterface */
private $userContext;
/** @var UserStoryRepositoryInterface */
private $userStoryRepository;
public function __construct(
Transaction $transaction,
UserContextInterface $userContext,
UserStoryRepositoryInterface $userStoryRepository
) {
$this->transaction = $transaction;
$this->userContext = $userContext;
$this->userStoryRepository = $userStoryRepository;
}
public function addUserStory(AddUserStoryCommand $command)
{
$this->transaction->scope(function () use ($command) {
$id = new UserStoryId(uniqid());
$story = new UserStory(
$id,
$command->getStory(),
$this->userContext->getId(),
$command->getDemo()
);
$this->userStoryRepository->save($story);
});
}
}