1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* webtrees: online genealogy |
5
|
|
|
* Copyright (C) 2021 webtrees development team |
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
7
|
|
|
* it under the terms of the GNU General Public License as published by |
8
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
9
|
|
|
* (at your option) any later version. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13
|
|
|
* GNU General Public License for more details. |
14
|
|
|
* You should have received a copy of the GNU General Public License |
15
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
16
|
|
|
*/ |
17
|
|
|
|
18
|
|
|
declare(strict_types=1); |
19
|
|
|
|
20
|
|
|
namespace Fisharebest\Webtrees; |
21
|
|
|
|
22
|
|
|
use Fisharebest\Webtrees\Contracts\FamilyFactoryInterface; |
23
|
|
|
use Fisharebest\Webtrees\Contracts\GedcomRecordFactoryInterface; |
24
|
|
|
use Fisharebest\Webtrees\Contracts\HeaderFactoryInterface; |
25
|
|
|
use Fisharebest\Webtrees\Contracts\IndividualFactoryInterface; |
26
|
|
|
use Fisharebest\Webtrees\Contracts\LocationFactoryInterface; |
27
|
|
|
use Fisharebest\Webtrees\Contracts\MarkdownFactoryInterface; |
28
|
|
|
use Fisharebest\Webtrees\Contracts\MediaFactoryInterface; |
29
|
|
|
use Fisharebest\Webtrees\Contracts\NoteFactoryInterface; |
30
|
|
|
use Fisharebest\Webtrees\Contracts\RepositoryFactoryInterface; |
31
|
|
|
use Fisharebest\Webtrees\Contracts\SourceFactoryInterface; |
32
|
|
|
use Fisharebest\Webtrees\Contracts\SubmissionFactoryInterface; |
33
|
|
|
use Fisharebest\Webtrees\Contracts\SubmitterFactoryInterface; |
34
|
|
|
use Fisharebest\Webtrees\Contracts\XrefFactoryInterface; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* A service locator for our various factory objects. |
38
|
|
|
* |
39
|
|
|
* @deprecated - will be removed in 2.1.0 - use Registry instead. |
40
|
|
|
*/ |
41
|
|
|
class Factory |
42
|
|
|
{ |
43
|
|
|
/** |
44
|
|
|
* Store or retrieve a factory object. |
45
|
|
|
* |
46
|
|
|
* @param FamilyFactoryInterface|null $factory |
47
|
|
|
* |
48
|
|
|
* @return FamilyFactoryInterface |
49
|
|
|
*/ |
50
|
|
|
public static function family(FamilyFactoryInterface $factory = null): FamilyFactoryInterface |
51
|
|
|
{ |
52
|
|
|
return Registry::familyFactory($factory); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Store or retrieve a factory object. |
57
|
|
|
* |
58
|
|
|
* @param GedcomRecordFactoryInterface|null $factory |
59
|
|
|
* |
60
|
|
|
* @return GedcomRecordFactoryInterface |
61
|
|
|
*/ |
62
|
|
|
public static function gedcomRecord(GedcomRecordFactoryInterface $factory = null): GedcomRecordFactoryInterface |
63
|
|
|
{ |
64
|
|
|
return Registry::gedcomRecordFactory($factory); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Store or retrieve a factory object. |
69
|
|
|
* |
70
|
|
|
* @param HeaderFactoryInterface|null $factory |
71
|
|
|
* |
72
|
|
|
* @return HeaderFactoryInterface |
73
|
|
|
*/ |
74
|
|
|
public static function header(HeaderFactoryInterface $factory = null): HeaderFactoryInterface |
75
|
|
|
{ |
76
|
|
|
return Registry::headerFactory($factory); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Store or retrieve a factory object. |
81
|
|
|
* |
82
|
|
|
* @param IndividualFactoryInterface|null $factory |
83
|
|
|
* |
84
|
|
|
* @return IndividualFactoryInterface |
85
|
|
|
*/ |
86
|
|
|
public static function individual(IndividualFactoryInterface $factory = null): IndividualFactoryInterface |
87
|
|
|
{ |
88
|
|
|
return Registry::individualFactory($factory); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Store or retrieve a factory object. |
93
|
|
|
* |
94
|
|
|
* @param LocationFactoryInterface|null $factory |
95
|
|
|
* |
96
|
|
|
* @return LocationFactoryInterface |
97
|
|
|
*/ |
98
|
|
|
public static function location(LocationFactoryInterface $factory = null): LocationFactoryInterface |
99
|
|
|
{ |
100
|
|
|
return Registry::locationFactory($factory); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Store or retrieve a factory object. |
105
|
|
|
* |
106
|
|
|
* @param MarkdownFactoryInterface|null $factory |
107
|
|
|
* |
108
|
|
|
* @return MarkdownFactoryInterface |
109
|
|
|
*/ |
110
|
|
|
public static function markdown(MarkdownFactoryInterface $factory = null): MarkdownFactoryInterface |
111
|
|
|
{ |
112
|
|
|
return Registry::markdownFactory($factory); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Store or retrieve a factory object. |
117
|
|
|
* |
118
|
|
|
* @param MediaFactoryInterface|null $factory |
119
|
|
|
* |
120
|
|
|
* @return MediaFactoryInterface |
121
|
|
|
*/ |
122
|
|
|
public static function media(MediaFactoryInterface $factory = null): MediaFactoryInterface |
123
|
|
|
{ |
124
|
|
|
return Registry::mediaFactory($factory); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Store or retrieve a factory object. |
129
|
|
|
* |
130
|
|
|
* @param NoteFactoryInterface|null $factory |
131
|
|
|
* |
132
|
|
|
* @return NoteFactoryInterface |
133
|
|
|
*/ |
134
|
|
|
public static function note(NoteFactoryInterface $factory = null): NoteFactoryInterface |
135
|
|
|
{ |
136
|
|
|
return Registry::noteFactory($factory); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Store or retrieve a factory object. |
141
|
|
|
* |
142
|
|
|
* @param RepositoryFactoryInterface|null $factory |
143
|
|
|
* |
144
|
|
|
* @return RepositoryFactoryInterface |
145
|
|
|
*/ |
146
|
|
|
public static function repository(RepositoryFactoryInterface $factory = null): RepositoryFactoryInterface |
147
|
|
|
{ |
148
|
|
|
return Registry::repositoryFactory($factory); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Store or retrieve a factory object. |
153
|
|
|
* |
154
|
|
|
* @param SourceFactoryInterface|null $factory |
155
|
|
|
* |
156
|
|
|
* @return SourceFactoryInterface |
157
|
|
|
*/ |
158
|
|
|
public static function source(SourceFactoryInterface $factory = null): SourceFactoryInterface |
159
|
|
|
{ |
160
|
|
|
return Registry::sourceFactory($factory); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Store or retrieve a factory object. |
165
|
|
|
* |
166
|
|
|
* @param SubmissionFactoryInterface|null $factory |
167
|
|
|
* |
168
|
|
|
* @return SubmissionFactoryInterface |
169
|
|
|
*/ |
170
|
|
|
public static function submission(SubmissionFactoryInterface $factory = null): SubmissionFactoryInterface |
171
|
|
|
{ |
172
|
|
|
return Registry::submissionFactory($factory); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
/** |
176
|
|
|
* Store or retrieve a factory object. |
177
|
|
|
* |
178
|
|
|
* @param SubmitterFactoryInterface|null $factory |
179
|
|
|
* |
180
|
|
|
* @return SubmitterFactoryInterface |
181
|
|
|
*/ |
182
|
|
|
public static function submitter(SubmitterFactoryInterface $factory = null): SubmitterFactoryInterface |
183
|
|
|
{ |
184
|
|
|
return Registry::submitterFactory($factory); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
/** |
188
|
|
|
* Store or retrieve a factory object. |
189
|
|
|
* |
190
|
|
|
* @param XrefFactoryInterface|null $factory |
191
|
|
|
* |
192
|
|
|
* @return XrefFactoryInterface |
193
|
|
|
*/ |
194
|
|
|
public static function xref(XrefFactoryInterface $factory = null): XrefFactoryInterface |
195
|
|
|
{ |
196
|
|
|
return Registry::xrefFactory($factory); |
197
|
|
|
} |
198
|
|
|
} |
199
|
|
|
|