Skip to content

Commit

Permalink
Fix compatibility with nette/application 3.2.3
Browse files Browse the repository at this point in the history
nette/application@850ab85
moved link generation to a new LinkGenerator class that must be instantiated or creating links will fail:

    Unable to create link to other presenter, service PresenterFactory or Router has not been set.

In order for LinkGenerator to be instantiated, we need to pass a IPresenterFactory when instantiating a Presenter.
Let’s make our PresenterFactory trivially implement the interface so that it can be used.
  • Loading branch information
jtojnar committed May 7, 2024
1 parent 24c3a72 commit 7b3ae7a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/Components/PresenterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Latte\Engine;
use Nette\Application\IPresenter;
use Nette\Application\IPresenterFactory;
use Nette\Application\UI;
use Nette\Bridges\ApplicationLatte\TemplateFactory;
use Nette\Http\IRequest;
Expand All @@ -16,10 +17,22 @@
use WebChemistry\Testing\Components\Helpers\RouterStub;
use WebChemistry\Testing\Components\Requests\PresenterRequest;

class PresenterFactory {
class PresenterFactory implements IPresenterFactory {
/** @var callable[] */
public array $onCreate = [];

/**
* Generates and checks presenter class name.
* @throws InvalidPresenterException
*/
function getPresenterClass(string &$name): string {
if (!class_exists($name)) {
throw new InvalidPresenterException("Cannot load presenter '$class', class '$class' was not found.");
}

return $name;
}

/**
* @return IPresenter|UI\Presenter
*/
Expand All @@ -33,7 +46,7 @@ public function createPresenter(string $class): IPresenter {
$presenter->injectPrimary(
$request,
new Response(),
null,
$this,
new RouterStub(),
null,
null,
Expand Down

0 comments on commit 7b3ae7a

Please sign in to comment.