/
AddDesignerSlotToBoardCommandHandler.php
48 lines (38 loc) · 1.43 KB
/
AddDesignerSlotToBoardCommandHandler.php
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
48
<?php
namespace Concrete\Core\Board\Designer\Command;
use Concrete\Core\Board\Designer\Command\AddDesignerSlotToBoardCommand;
use Concrete\Core\Entity\Board\InstanceSlotRule;
use Concrete\Core\User\User;
use Doctrine\ORM\EntityManager;
class AddDesignerSlotToBoardCommandHandler
{
/**
* @var EntityManager
*/
protected $entityManager;
public function __construct(EntityManager $entityManager)
{
$this->entityManager = $entityManager;
}
public function __invoke(AddDesignerSlotToBoardCommand $command)
{
$dateCreated = new \DateTime();
$dateCreated->setTimezone(new \DateTimeZone($command->getTimezone()));
$slot = $command->getSlot();
$rule = new InstanceSlotRule();
$rule->setInstance($command->getInstance());
$rule->setSlot($slot);
$rule->setDateCreated($dateCreated->getTimestamp());
$rule->setTimezone($command->getTimezone());
$rule->setUser($command->getUser());
$rule->setIsLocked($command->isLocked());
$rule->setBatchIdentifier($command->getBatchIdentifier());
$rule->setStartDate($command->getStartDate());
$rule->setEndDate($command->getEndDate());
$rule->setBlockID($command->getBlockID());
$rule->setRuleType($command->getRuleType());
$rule->setNotes($command->getNotes());
$this->entityManager->persist($rule);
$this->entityManager->flush();
}
}