|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Superdesk Web Publisher MultiTenancy Component. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright 2015 Sourcefabric z.u. and contributors. |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please see the |
|
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
10
|
|
|
* |
|
11
|
|
|
* @copyright 2015 Sourcefabric z.ú. |
|
12
|
|
|
* @license http://www.superdesk.org/license |
|
13
|
|
|
*/ |
|
14
|
|
|
namespace SWP\Component\MultiTenancy\Model; |
|
15
|
|
|
|
|
16
|
|
|
use SWP\Component\Common\Model\EnableableTrait; |
|
17
|
|
|
use SWP\Component\Common\Model\SoftDeletableTrait; |
|
18
|
|
|
use SWP\Component\Common\Model\TimestampableTrait; |
|
19
|
|
|
|
|
20
|
|
|
class Tenant implements TenantInterface |
|
21
|
|
|
{ |
|
22
|
|
|
use SoftDeletableTrait, TimestampableTrait, EnableableTrait; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var mixed |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $id; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $subdomain; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var string |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $name; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $code; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var OrganizationInterface |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $organization; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Tenant constructor. |
|
51
|
|
|
*/ |
|
52
|
|
|
public function __construct() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->createdAt = new \DateTime(); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* {@inheritdoc} |
|
59
|
|
|
*/ |
|
60
|
|
|
public function getId() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->id; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {@inheritdoc} |
|
67
|
|
|
*/ |
|
68
|
|
|
public function setId($id) |
|
69
|
|
|
{ |
|
70
|
|
|
$this->id = $id; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* {@inheritdoc} |
|
75
|
|
|
*/ |
|
76
|
|
|
public function getSubdomain() |
|
77
|
|
|
{ |
|
78
|
|
|
return $this->subdomain; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* {@inheritdoc} |
|
83
|
|
|
*/ |
|
84
|
|
|
public function setSubdomain($subdomain) |
|
85
|
|
|
{ |
|
86
|
|
|
$this->subdomain = $subdomain; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* {@inheritdoc} |
|
91
|
|
|
*/ |
|
92
|
|
|
public function getName() |
|
93
|
|
|
{ |
|
94
|
|
|
return $this->name; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* {@inheritdoc} |
|
99
|
|
|
*/ |
|
100
|
|
|
public function setName($name) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->name = $name; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* {@inheritdoc} |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getCode() |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->code; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* {@inheritdoc} |
|
115
|
|
|
*/ |
|
116
|
|
|
public function setCode($code) |
|
117
|
|
|
{ |
|
118
|
|
|
if (null !== $this->code) { |
|
119
|
|
|
throw new \LogicException('Tenant\'s code is already set. Can not change it.'); |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
$this->code = $code; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* {@inheritdoc} |
|
127
|
|
|
*/ |
|
128
|
|
|
public function setOrganization(OrganizationInterface $organization) |
|
129
|
|
|
{ |
|
130
|
|
|
$this->organization = $organization; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* {@inheritdoc} |
|
135
|
|
|
*/ |
|
136
|
|
|
public function getOrganization() |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->organization; |
|
139
|
|
|
} |
|
140
|
|
|
|
|
141
|
|
|
/** |
|
142
|
|
|
* @return string |
|
143
|
|
|
*/ |
|
144
|
|
|
public function __toString() |
|
145
|
|
|
{ |
|
146
|
|
|
return (string) $this->subdomain; |
|
147
|
|
|
} |
|
148
|
|
|
} |
|
149
|
|
|
|