exception in application: pass reference to previous presenter#317
Merged
dg merged 43 commits intonette:masterfrom Oct 6, 2023
Merged
exception in application: pass reference to previous presenter#317dg merged 43 commits intonette:masterfrom
dg merged 43 commits intonette:masterfrom
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)
Contributor
|
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));
}
}
} |
Member
|
Isn't it easier to inject an Application into the errorpresenter? |
Contributor
Author
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
Contributor
Author
|
Thank you! |
dg
pushed a commit
that referenced
this pull request
Oct 8, 2023
dg
pushed a commit
that referenced
this pull request
Oct 9, 2023
dg
pushed a commit
that referenced
this pull request
Oct 9, 2023
dg
pushed a commit
that referenced
this pull request
Oct 9, 2023
dg
pushed a commit
that referenced
this pull request
Oct 9, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: