-
-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
exception in application: pass reference to previous presenter #317
Conversation
…e() for persistent parameters. [Closes nette/nette#703]" (possible BC break) This reverts commit cda17f4. See https://forum.nette.org/cs/35528-stejne-pojmenovany-parametr-akce-presenteru-a-persistentni-odlisne-chovani-v-nette-2-0-oproti-aktualnimu#p221742 BC break: Property must be nullable, ie: #[Persistent] public ?int $foo
…aced by Nette\Routing\Router)
So, you don't need an instance? class ErrorPresenter extends Presenter
{
public function __construct(private readonly IPresenterFactory $presenterFactory) {}
public function actionDefault(Throwable $exception, Request|null $request): void
{
$presenterName = $request?->getPresenterName() ?? null;
if ($presenterName !== null) {
$presenterClass = $this->presenterFactory->getPresenterClass($presenterName);
dump(is_a($presenterClass, CheckedInterface::class, true));
}
}
} |
Isn't it easier to inject an Application into the errorpresenter? |
No. Even though your solution work, it seems strange to me to work with presenter factory inside of presenter. Extracting the presenter router<->class name translation into separate single responsibility service would probably solve that. Does it make sense?
What would I do then? I can see My proposal seems quite straightforward to me, is there any problem with it? |
e3a690a
to
4e12415
Compare
Thank you! |
I need separate handling of bad request of presenters that implement some interface. To check this in error presenter, I need instance of the original presenter therefore this PR. It can be probably achieved also via reflection, but this it seems cleaner to me.
todo: