Skip to content

Commit

Permalink
webtrees 2.2 support added
Browse files Browse the repository at this point in the history
  • Loading branch information
UksusoFF committed Dec 3, 2024
1 parent 44c6619 commit f20330a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/Helpers/AppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@

class AppHelper
{
/**
* @param string $class
* @return mixed
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Exception
*/
public static function get(string $class)
{
if (version_compare(Webtrees::VERSION, '2.2.0', '>=')) {
if (version_compare(Webtrees::VERSION, '2.2.0', '>=')) {// @phpstan-ignore-line
return \Fisharebest\Webtrees\Registry::container()->get($class);
}

if (function_exists('app')) {
if (function_exists('app')) {// @phpstan-ignore-line
return app($class);
}

Expand Down
8 changes: 7 additions & 1 deletion src/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace UksusoFF\WebtreesModules\Faces\Http\Controllers;

use Exception;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Http\Exceptions\HttpAccessDeniedException;
use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
Expand Down Expand Up @@ -152,9 +153,14 @@ private function prepareRow($row): array
return $item['pid'];
}, json_decode($row->f_coordinates, true)));

try {
$tree = $this->trees->find((int) $row->m_file);
} catch (Exception $e) {
return $this->rowMissed($row, $pids);
}

if (
$row->m_file === null ||
($tree = $this->trees->find((int) $row->m_file)) === null ||
($media = Registry::mediaFactory()->make($row->f_m_id, $tree)) === null ||
($file = $this->module->media->getMediaImageFileByOrder($media, (int) $row->f_m_order)) === null
) {
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/DataController.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private function getMediaMapForTree(Media $media, string $fact): array
}

if (!empty($result)) {
foreach ($this->module->query->getIndividualsDataByTreeAndPids($media->tree()->id(), $pids) as $row) {
foreach ($this->module->query->getIndividualsDataByTreeAndPids((string) $media->tree()->id(), $pids) as $row) {
$person = Registry::individualFactory()->make($row->xref, $media->tree(), $row->gedcom);
if ($person === null) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion src/Modules/FacesModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class FacesModule extends AbstractModule implements ModuleCustomInterface, Modul
use ModuleConfigTrait;
use ModuleTabTrait;

public const SCHEMA_VERSION = '7';
public const SCHEMA_VERSION = 7;

public const CUSTOM_VERSION = '2.7.3';

Expand Down

0 comments on commit f20330a

Please sign in to comment.