summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2021-01-28 15:06:19 +0000
committerGreg Roach <greg@subaqua.co.uk>2021-01-28 15:09:29 +0000
commitd4ac8227583d99594747232b484d914927c96ef1 (patch)
tree84f49bf6979206c1a8abb5181eeeeb6239e74215 /app
parentb4250c5cea6f65a6cd2b476c0a937173ca8c6b13 (diff)
downloadwebtrees-d4ac8227583d99594747232b484d914927c96ef1.tar.gz
webtrees-d4ac8227583d99594747232b484d914927c96ef1.tar.bz2
webtrees-d4ac8227583d99594747232b484d914927c96ef1.zip
Merge some changes from 2.1
Diffstat (limited to 'app')
-rw-r--r--app/Family.php4
-rw-r--r--app/GedcomRecord.php4
-rw-r--r--app/Header.php4
-rw-r--r--app/Http/RequestHandlers/AbstractSelect2Handler.php2
-rw-r--r--app/Individual.php4
-rw-r--r--app/Media.php4
-rw-r--r--app/Note.php4
-rw-r--r--app/Repository.php4
-rw-r--r--app/Services/DataFixService.php2
-rw-r--r--app/Services/SearchService.php72
-rw-r--r--app/Source.php4
-rw-r--r--app/Submission.php4
-rw-r--r--app/Submitter.php4
13 files changed, 94 insertions, 22 deletions
diff --git a/app/Family.php b/app/Family.php
index ff8363a768..29113270d4 100644
--- a/app/Family.php
+++ b/app/Family.php
@@ -66,7 +66,7 @@ class Family extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::family()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::familyFactory()
*
* @param Tree $tree
*
@@ -94,7 +94,7 @@ class Family extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::family()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::familyFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/GedcomRecord.php b/app/GedcomRecord.php
index bece1731b0..81b288c694 100644
--- a/app/GedcomRecord.php
+++ b/app/GedcomRecord.php
@@ -112,7 +112,7 @@ class GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::gedcomRecord()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::gedcomRecordFactory()
*
* @param Tree $tree
*
@@ -178,7 +178,7 @@ class GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::gedcomRecord()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::gedcomRecordFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Header.php b/app/Header.php
index 7ec9c32f01..08f498095e 100644
--- a/app/Header.php
+++ b/app/Header.php
@@ -34,7 +34,7 @@ class Header extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::header()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::headerFactory()
*
* @param Tree $tree
*
@@ -50,7 +50,7 @@ class Header extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::header()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::headerFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Http/RequestHandlers/AbstractSelect2Handler.php b/app/Http/RequestHandlers/AbstractSelect2Handler.php
index ad90a58311..d71ae4a489 100644
--- a/app/Http/RequestHandlers/AbstractSelect2Handler.php
+++ b/app/Http/RequestHandlers/AbstractSelect2Handler.php
@@ -55,8 +55,8 @@ abstract class AbstractSelect2Handler implements RequestHandlerInterface
$params = (array) $request->getParsedBody();
$query = $params['q'] ?? '';
- $at = (bool) ($params['at'] ?? false);
$page = (int) ($params['page'] ?? 1);
+ $at = (bool) ($request->getQueryParams()['at'] ?? false);
// Fetch one more row than we need, so we can know if more rows exist.
$offset = ($page - 1) * self::RESULTS_PER_PAGE;
diff --git a/app/Individual.php b/app/Individual.php
index 0b2d18b65b..c5bbd0f70c 100644
--- a/app/Individual.php
+++ b/app/Individual.php
@@ -53,7 +53,7 @@ class Individual extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::individual()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::individualFactory()
*
* @param Tree $tree
*
@@ -93,7 +93,7 @@ class Individual extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::individual()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::individualFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Media.php b/app/Media.php
index f6fa6f39d0..d7321ef2d2 100644
--- a/app/Media.php
+++ b/app/Media.php
@@ -37,7 +37,7 @@ class Media extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::media()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::mediaFactory()
*
* @param Tree $tree
*
@@ -53,7 +53,7 @@ class Media extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::media()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::mediaFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Note.php b/app/Note.php
index beea1c7bc9..eb5022c9ca 100644
--- a/app/Note.php
+++ b/app/Note.php
@@ -36,7 +36,7 @@ class Note extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::note()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::noteFactory()
*
* @param Tree $tree
*
@@ -52,7 +52,7 @@ class Note extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::note()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::noteFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Repository.php b/app/Repository.php
index 9230ac8145..a8b95ea2c7 100644
--- a/app/Repository.php
+++ b/app/Repository.php
@@ -34,7 +34,7 @@ class Repository extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::repository()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::repositoryFactory()
*
* @param Tree $tree
*
@@ -50,7 +50,7 @@ class Repository extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::repository()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::repositoryFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Services/DataFixService.php b/app/Services/DataFixService.php
index a624501921..a9d62a77e9 100644
--- a/app/Services/DataFixService.php
+++ b/app/Services/DataFixService.php
@@ -44,7 +44,7 @@ use function strip_tags;
class DataFixService
{
/**
- * Since we know the type, this is quicker than calling Factory::gedcomRecord()->make().
+ * Since we know the type, this is quicker than calling Registry::gedcomRecordFactory()->make().
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Services/SearchService.php b/app/Services/SearchService.php
index 942eb65435..e1675e24e4 100644
--- a/app/Services/SearchService.php
+++ b/app/Services/SearchService.php
@@ -22,6 +22,7 @@ namespace Fisharebest\Webtrees\Services;
use Closure;
use Fisharebest\Webtrees\Date;
use Fisharebest\Webtrees\Exceptions\HttpServiceUnavailableException;
+use Fisharebest\Webtrees\Location;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Gedcom;
@@ -34,6 +35,7 @@ use Fisharebest\Webtrees\Place;
use Fisharebest\Webtrees\Repository;
use Fisharebest\Webtrees\Soundex;
use Fisharebest\Webtrees\Source;
+use Fisharebest\Webtrees\Submission;
use Fisharebest\Webtrees\Submitter;
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Capsule\Manager as DB;
@@ -232,6 +234,27 @@ class SearchService
}
/**
+ * Search for submissions.
+ *
+ * @param Tree[] $trees
+ * @param string[] $search
+ * @param int $offset
+ * @param int $limit
+ *
+ * @return Collection<Location>
+ */
+ public function searchLocations(array $trees, array $search, int $offset = 0, int $limit = PHP_INT_MAX): Collection
+ {
+ $query = DB::table('other')
+ ->where('o_type', '=', '_LOC');
+
+ $this->whereTrees($query, 'o_file', $trees);
+ $this->whereSearch($query, 'o_gedcom', $search);
+
+ return $this->paginateQuery($query, $this->locationRowMapper(), GedcomRecord::accessFilter(), $offset, $limit);
+ }
+
+ /**
* Search for media objects.
*
* @param Tree[] $trees
@@ -360,6 +383,27 @@ class SearchService
}
/**
+ * Search for submissions.
+ *
+ * @param Tree[] $trees
+ * @param string[] $search
+ * @param int $offset
+ * @param int $limit
+ *
+ * @return Collection<Submission>
+ */
+ public function searchSubmissions(array $trees, array $search, int $offset = 0, int $limit = PHP_INT_MAX): Collection
+ {
+ $query = DB::table('other')
+ ->where('o_type', '=', 'SUBN');
+
+ $this->whereTrees($query, 'o_file', $trees);
+ $this->whereSearch($query, 'o_gedcom', $search);
+
+ return $this->paginateQuery($query, $this->submissionRowMapper(), GedcomRecord::accessFilter(), $offset, $limit);
+ }
+
+ /**
* Search for submitters.
*
* @param Tree[] $trees
@@ -1160,6 +1204,20 @@ class SearchService
}
/**
+ * Convert a row from any tree in the media table into a location object.
+ *
+ * @return Closure
+ */
+ private function locationRowMapper(): Closure
+ {
+ return function (stdClass $row): Media {
+ $tree = $this->tree_service->find((int) $row->m_file);
+
+ return Registry::locationFactory()->mapper($tree)($row);
+ };
+ }
+
+ /**
* Convert a row from any tree in the media table into an media object.
*
* @return Closure
@@ -1216,6 +1274,20 @@ class SearchService
}
/**
+ * Convert a row from any tree in the other table into a submission object.
+ *
+ * @return Closure
+ */
+ private function submissionRowMapper(): Closure
+ {
+ return function (stdClass $row): Submission {
+ $tree = $this->tree_service->find((int) $row->o_file);
+
+ return Registry::submissionFactory()->mapper($tree)($row);
+ };
+ }
+
+ /**
* Convert a row from any tree in the other table into a submitter object.
*
* @return Closure
diff --git a/app/Source.php b/app/Source.php
index 92559b3c49..65ed8108e8 100644
--- a/app/Source.php
+++ b/app/Source.php
@@ -35,7 +35,7 @@ class Source extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::source()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::sourceFactory()
*
* @param Tree $tree
*
@@ -51,7 +51,7 @@ class Source extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::source()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::sourceFactory()
*
* @param string $xref
* @param Tree $tree
diff --git a/app/Submission.php b/app/Submission.php
index 2268a2a86b..a9c22c9bb3 100644
--- a/app/Submission.php
+++ b/app/Submission.php
@@ -37,7 +37,7 @@ class Submission extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::submission()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::submissionFactory()
*
* @param Tree $tree
*
@@ -57,7 +57,7 @@ class Submission extends GedcomRecord
* @param Tree $tree
* @param string|null $gedcom
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::submission()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::submissionFactory()
*
* @return Submission|null
*/
diff --git a/app/Submitter.php b/app/Submitter.php
index 08b827f933..5f17b59915 100644
--- a/app/Submitter.php
+++ b/app/Submitter.php
@@ -34,7 +34,7 @@ class Submitter extends GedcomRecord
/**
* A closure which will create a record from a database row.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::submitter()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::submitterFactory()
*
* @param Tree $tree
*
@@ -50,7 +50,7 @@ class Submitter extends GedcomRecord
* we just receive the XREF. For bulk records (such as lists
* and search results) we can receive the GEDCOM data as well.
*
- * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Factory::submitter()
+ * @deprecated since 2.0.4. Will be removed in 2.1.0 - Use Registry::submitterFactory()
*
* @param string $xref
* @param Tree $tree