Skip to content

Commit

Permalink
Merge pull request #541 from Neriderc/fix-webtrees-2.2
Browse files Browse the repository at this point in the history
Fix webtrees 2.2 - webtrees 2.1.X no longer supported
  • Loading branch information
Neriderc authored Nov 26, 2024
2 parents 74f779f + e96b7d0 commit 651d43e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions app/ApiHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\ServerRequestInterface;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\Registry;

Check warning on line 12 in app/ApiHandler.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'


/**
Expand Down Expand Up @@ -43,8 +44,8 @@ public function __construct(ServerRequestInterface $request, GVExport $module, T
* @return mixed
*/
public function getResponse() {
$stream = app(StreamFactoryInterface::class)->createStream(json_encode($this->response_data));
$response_factory = app(ResponseFactoryInterface::class);
$stream = Registry::container()->get(StreamFactoryInterface::class)->createStream(json_encode($this->response_data));

Check warning on line 47 in app/ApiHandler.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
$response_factory = Registry::container()->get(ResponseFactoryInterface::class);

Check warning on line 48 in app/ApiHandler.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
return $response_factory->createResponse()
->withBody($stream)
->withHeader('Content-Type', "application/json");
Expand Down
10 changes: 6 additions & 4 deletions app/Favourite.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Fisharebest\Webtrees\Module\FamilyTreeFavoritesModule;
use Fisharebest\Webtrees\Module\UserFavoritesModule;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\Registry;

Check warning on line 9 in app/Favourite.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'


/**
* GVExport representation of a webtrees Favourite
Expand Down Expand Up @@ -57,9 +59,9 @@ private function addUserFavourite(Tree $tree, string $url, string $title): bool
$note = "";
$user = Auth::user();
$favorite = function ($tree, $user, $url, $title, $note) {
return app(UserFavoritesModule::class)->addUrlFavorite($tree, $user, $url, $title, $note);
return Registry::container()->get(UserFavoritesModule::class)->addUrlFavorite($tree, $user, $url, $title, $note);

Check warning on line 62 in app/Favourite.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
};
$favorite->call(app(UserFavoritesModule::class), $tree, $user, $url, $title, $note);
$favorite->call(Registry::container()->get(UserFavoritesModule::class), $tree, $user, $url, $title, $note);

Check warning on line 64 in app/Favourite.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
return true;
}

Expand All @@ -75,9 +77,9 @@ private function addTreeFavourite(Tree $tree, string $url, string $title): bool
{
$note = "";
$favorite = function ($tree, $url, $title, $note) {
return app(FamilyTreeFavoritesModule::class)->addUrlFavorite($tree, $url, $title, $note);
return Registry::container()->get(FamilyTreeFavoritesModule::class)->addUrlFavorite($tree, $url, $title, $note);

Check warning on line 80 in app/Favourite.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
};
$favorite->call(app(FamilyTreeFavoritesModule::class), $tree, $url, $title, $note);
$favorite->call(Registry::container()->get(FamilyTreeFavoritesModule::class), $tree, $url, $title, $note);

Check warning on line 82 in app/Favourite.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
return true;
}
}
5 changes: 3 additions & 2 deletions app/OutputFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Fisharebest\Webtrees\Registry;

Check warning on line 10 in app/OutputFile.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'

Check warning on line 10 in app/OutputFile.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined namespace

Undefined namespace 'Webtrees'


/**
Expand Down Expand Up @@ -35,7 +36,7 @@ function __construct($temp_dir, $file_type, $module) {
function downloadFile()
{
$stream = $this->getFileStream();
$response_factory = app(ResponseFactoryInterface::class);
$response_factory = Registry::container()->get(ResponseFactoryInterface::class);

Check warning on line 39 in app/OutputFile.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
return $response_factory->createResponse()
->withBody($stream)
->withHeader('Content-Type', $this->settings['graphviz_config']['output'][$this->fileType]['cont_type'])
Expand All @@ -58,7 +59,7 @@ private function getFileStream() {
}
}

return app(StreamFactoryInterface::class)->createStreamFromFile($filename);
return Registry::container()->get(StreamFactoryInterface::class)->createStreamFromFile($filename);

Check warning on line 62 in app/OutputFile.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
}

}
5 changes: 3 additions & 2 deletions module.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GVExport extends AbstractModule implements ModuleCustomInterface, ModuleCh
use ModuleCustomTrait;
use ModuleChartTrait;
use ModuleConfigTrait;
public const CUSTOM_VERSION = '2.1.23';
public const CUSTOM_VERSION = '2.2.1';
public const CUSTOM_MODULE = "GVExport";
public const CUSTOM_LATEST = 'https://raw.githubusercontent.com/Neriderc/' . self::CUSTOM_MODULE. '/main/latest-version.txt';
public const SUPPORT_URL = 'https://github.com/Neriderc/GVExport';
Expand Down Expand Up @@ -433,4 +433,5 @@ private function strip_param_from_url($url, $param): string
}
}

return Webtrees::make(GVExport::class);
$moduleService = Registry::container()->get(ModuleService::class);

Check warning on line 436 in module.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'ModuleService'

Check warning on line 436 in module.php

View workflow job for this annotation

GitHub Actions / Qodana for PHP

Undefined class

Undefined class 'Registry'
return new GVExport($moduleService);

0 comments on commit 651d43e

Please sign in to comment.