-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathAdministrationService.php
More file actions
47 lines (39 loc) · 1.16 KB
/
AdministrationService.php
File metadata and controls
47 lines (39 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* This file is part of the php-ddd project.
*
* (c) Yannick Voyer <star.yvoyer@gmail.com> (http://github.com/yvoyer)
*/
namespace Example\Domain\Administration\Application;
use Example\Domain\Administration\DomainModel\OwnerRepository;
use Example\Domain\Common\Application\EventPublisher;
final class AdministrationService
{
/**
* @var OwnerRepository
*/
private $ownerRepository;
/**
* @var EventPublisher
*/
private $publisher;
/**
* @param OwnerRepository $ownerRepository
* @param EventPublisher $publisher
*/
public function __construct(OwnerRepository $ownerRepository, EventPublisher $publisher)
{
$this->ownerRepository = $ownerRepository;
$this->publisher = $publisher;
}
/**
* @param HireCandidateCommand $command
*/
public function hireCandidate(HireCandidateCommand $command)
{
$owner = $this->ownerRepository->ownerWithId($command->hiredBy());
$owner->hire($command->candidateName(), $command->title());
$this->ownerRepository->saveOwner($owner);
$this->publisher->publish($owner->uncommitedEvents());
}
}