summaryrefslogtreecommitdiff
path: root/app/Factory.php
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2020-10-03 12:15:48 +0100
committerGreg Roach <greg@subaqua.co.uk>2020-10-03 12:15:48 +0100
commit6b9cb339562c8aa4681c7eff2bf3bdf401cc9edd (patch)
tree1f7bfd68d1cf96ea4ba9d8094ab931d9a0a405e8 /app/Factory.php
parentda616f3de48e91ba07cf8efe6aa888392c873a0c (diff)
downloadwebtrees-6b9cb339562c8aa4681c7eff2bf3bdf401cc9edd.tar.gz
webtrees-6b9cb339562c8aa4681c7eff2bf3bdf401cc9edd.tar.bz2
webtrees-6b9cb339562c8aa4681c7eff2bf3bdf401cc9edd.zip
#3529 - rename Factory to Registry
Diffstat (limited to 'app/Factory.php')
-rw-r--r--app/Factory.php170
1 files changed, 14 insertions, 156 deletions
diff --git a/app/Factory.php b/app/Factory.php
index b523edf54b..0242deba1b 100644
--- a/app/Factory.php
+++ b/app/Factory.php
@@ -19,12 +19,9 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees;
-use Fisharebest\Webtrees\Contracts\CacheFactoryInterface;
use Fisharebest\Webtrees\Contracts\FamilyFactoryInterface;
-use Fisharebest\Webtrees\Contracts\FilesystemFactoryInterface;
use Fisharebest\Webtrees\Contracts\GedcomRecordFactoryInterface;
use Fisharebest\Webtrees\Contracts\HeaderFactoryInterface;
-use Fisharebest\Webtrees\Contracts\ImageFactoryInterface;
use Fisharebest\Webtrees\Contracts\IndividualFactoryInterface;
use Fisharebest\Webtrees\Contracts\LocationFactoryInterface;
use Fisharebest\Webtrees\Contracts\MediaFactoryInterface;
@@ -37,70 +34,11 @@ use Fisharebest\Webtrees\Contracts\XrefFactoryInterface;
/**
* A service locator for our various factory objects.
+ *
+ * @deprecated - will be removed in 2.1.0 - use Registry instead.
*/
class Factory
{
- /** @var CacheFactoryInterface */
- private static $cache_factory;
-
- /** @var FamilyFactoryInterface */
- private static $family_factory;
-
- /** @var FilesystemFactoryInterface */
- private static $filesystem_factory;
-
- /** @var GedcomRecordFactoryInterface */
- private static $gedcom_record_factory;
-
- /** @var HeaderFactoryInterface */
- private static $header_factory;
-
- /** @var ImageFactoryInterface */
- private static $image_factory;
-
- /** @var IndividualFactoryInterface */
- private static $individual_factory;
-
- /** @var LocationFactoryInterface */
- private static $location_factory;
-
- /** @var MediaFactoryInterface */
- private static $media_factory;
-
- /** @var NoteFactoryInterface */
- private static $note_factory;
-
- /** @var RepositoryFactoryInterface */
- private static $repository_factory;
-
- /** @var SourceFactoryInterface */
- private static $source_factory;
-
- /** @var SubmissionFactoryInterface */
- private static $submission_factory;
-
- /** @var SubmitterFactoryInterface */
- private static $submitter_factory;
-
- /** @var XrefFactoryInterface */
- private static $xref_factory;
-
- /**
- * Store or retrieve a factory object.
- *
- * @param CacheFactoryInterface|null $factory
- *
- * @return CacheFactoryInterface
- */
- public static function cache(CacheFactoryInterface $factory = null): CacheFactoryInterface
- {
- if ($factory instanceof CacheFactoryInterface) {
- self::$cache_factory = $factory;
- }
-
- return self::$cache_factory;
- }
-
/**
* Store or retrieve a factory object.
*
@@ -110,27 +48,7 @@ class Factory
*/
public static function family(FamilyFactoryInterface $factory = null): FamilyFactoryInterface
{
- if ($factory instanceof FamilyFactoryInterface) {
- self::$family_factory = $factory;
- }
-
- return self::$family_factory;
- }
-
- /**
- * Store or retrieve a factory object.
- *
- * @param FilesystemFactoryInterface|null $factory
- *
- * @return FilesystemFactoryInterface
- */
- public static function filesystem(FilesystemFactoryInterface $factory = null): FilesystemFactoryInterface
- {
- if ($factory instanceof FilesystemFactoryInterface) {
- self::$filesystem_factory = $factory;
- }
-
- return self::$filesystem_factory;
+ return Registry::familyFactory($factory);
}
/**
@@ -142,11 +60,7 @@ class Factory
*/
public static function gedcomRecord(GedcomRecordFactoryInterface $factory = null): GedcomRecordFactoryInterface
{
- if ($factory instanceof GedcomRecordFactoryInterface) {
- self::$gedcom_record_factory = $factory;
- }
-
- return self::$gedcom_record_factory;
+ return Registry::gedcomRecordFactory($factory);
}
/**
@@ -158,27 +72,7 @@ class Factory
*/
public static function header(HeaderFactoryInterface $factory = null): HeaderFactoryInterface
{
- if ($factory instanceof HeaderFactoryInterface) {
- self::$header_factory = $factory;
- }
-
- return self::$header_factory;
- }
-
- /**
- * Store or retrieve a factory object.
- *
- * @param ImageFactoryInterface|null $factory
- *
- * @return ImageFactoryInterface
- */
- public static function image(ImageFactoryInterface $factory = null): ImageFactoryInterface
- {
- if ($factory instanceof ImageFactoryInterface) {
- self::$image_factory = $factory;
- }
-
- return self::$image_factory;
+ return Registry::headerFactory($factory);
}
/**
@@ -190,11 +84,7 @@ class Factory
*/
public static function individual(IndividualFactoryInterface $factory = null): IndividualFactoryInterface
{
- if ($factory instanceof IndividualFactoryInterface) {
- self::$individual_factory = $factory;
- }
-
- return self::$individual_factory;
+ return Registry::individualFactory($factory);
}
/**
@@ -206,11 +96,7 @@ class Factory
*/
public static function location(LocationFactoryInterface $factory = null): LocationFactoryInterface
{
- if ($factory instanceof LocationFactoryInterface) {
- self::$location_factory = $factory;
- }
-
- return self::$location_factory;
+ return Registry::locationFactory($factory);
}
/**
@@ -222,11 +108,7 @@ class Factory
*/
public static function media(MediaFactoryInterface $factory = null): MediaFactoryInterface
{
- if ($factory instanceof MediaFactoryInterface) {
- self::$media_factory = $factory;
- }
-
- return self::$media_factory;
+ return Registry::mediaFactory($factory);
}
/**
@@ -238,11 +120,7 @@ class Factory
*/
public static function note(NoteFactoryInterface $factory = null): NoteFactoryInterface
{
- if ($factory instanceof NoteFactoryInterface) {
- self::$note_factory = $factory;
- }
-
- return self::$note_factory;
+ return Registry::noteFactory($factory);
}
/**
@@ -254,11 +132,7 @@ class Factory
*/
public static function repository(RepositoryFactoryInterface $factory = null): RepositoryFactoryInterface
{
- if ($factory instanceof RepositoryFactoryInterface) {
- self::$repository_factory = $factory;
- }
-
- return self::$repository_factory;
+ return Registry::repositoryFactory($factory);
}
/**
@@ -270,11 +144,7 @@ class Factory
*/
public static function source(SourceFactoryInterface $factory = null): SourceFactoryInterface
{
- if ($factory instanceof SourceFactoryInterface) {
- self::$source_factory = $factory;
- }
-
- return self::$source_factory;
+ return Registry::sourceFactory($factory);
}
/**
@@ -286,11 +156,7 @@ class Factory
*/
public static function submission(SubmissionFactoryInterface $factory = null): SubmissionFactoryInterface
{
- if ($factory instanceof SubmissionFactoryInterface) {
- self::$submission_factory = $factory;
- }
-
- return self::$submission_factory;
+ return Registry::submissionFactory($factory);
}
/**
@@ -302,11 +168,7 @@ class Factory
*/
public static function submitter(SubmitterFactoryInterface $factory = null): SubmitterFactoryInterface
{
- if ($factory instanceof SubmitterFactoryInterface) {
- self::$submitter_factory = $factory;
- }
-
- return self::$submitter_factory;
+ return Registry::submitterFactory($factory);
}
/**
@@ -318,10 +180,6 @@ class Factory
*/
public static function xref(XrefFactoryInterface $factory = null): XrefFactoryInterface
{
- if ($factory instanceof XrefFactoryInterface) {
- self::$xref_factory = $factory;
- }
-
- return self::$xref_factory;
+ return Registry::xrefFactory($factory);
}
}