-
Notifications
You must be signed in to change notification settings - Fork 146
Expand file tree
/
Copy pathStartEvent.php
More file actions
82 lines (72 loc) · 1.68 KB
/
StartEvent.php
File metadata and controls
82 lines (72 loc) · 1.68 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*
* Copyright (c) Atsuhiro Kubo <kubo@iteman.jp> and contributors,
* All rights reserved.p
*
* This file is part of Workflower.
*
* This program and the accompanying materials are made available under
* the terms of the BSD 2-Clause License which accompanies this
* distribution, and is available at http://opensource.org/licenses/BSD-2-Clause
*/
namespace PHPMentors\Workflower\Workflow\Event;
use PHPMentors\Workflower\Workflow\Element\Token;
use PHPMentors\Workflower\Workflow\Element\TransitionalInterface;
class StartEvent extends Event implements EventInterface, TransitionalInterface, \Serializable
{
/**
* @var Token
*
* @since 2.0.0
*/
private $token;
/**
* @var \DateTime
*
* @since 2.0.0
*/
private $startDate;
/**
* {@inheritdoc}
*
* @since 2.0.0
*/
public function serialize()
{
return serialize([
get_parent_class($this) => parent::serialize(),
'token' => $this->token,
'startDate' => $this->startDate,
]);
}
/**
* {@inheritdoc}
*/
public function getToken(): iterable
{
return [$this->token];
}
/**
* {@inheritdoc}
*/
public function attachToken(Token $token): void
{
$this->token = $token;
$this->startDate = new \DateTime();
}
/**
* {@inheritdoc}
*/
public function detachToken(Token $token): void
{
assert($this->token->getId() == $token->getId());
$this->token = null;
}
/**
* @return \DateTime|null
*/
public function getStartDate(): ?\DateTime
{
return $this->startDate;
}
}