Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Notifier] Fix extensibility ofNotification class#46172

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
andersonamuller wants to merge1 commit intosymfony:5.4fromandersonamuller:patch-3
Closed

[Notifier] Fix extensibility ofNotification class#46172

andersonamuller wants to merge1 commit intosymfony:5.4fromandersonamuller:patch-3

Conversation

@andersonamuller
Copy link
Contributor

QA
Branch?5.4
Bug fix?no
New feature????
Deprecations?no
Tickets
LicenseMIT
Doc PR

Without using static it kills the extensibility of theNotification class as theexception andexceptionAsString properties are private and other methods such asEmailMessage::fromNotification use that to customize the message to send to channels.

Without using static it kills the extensibility of the `Notification` class as the `exception` and `exceptionAsString` properties are private and other methods such as `EmailMessage::fromNotification` use that to customize the message to send to channels.
$parts =explode('\\',\get_class($exception));

$notification =newself(sprintf('%s: %s',array_pop($parts),$exception->getMessage()),$channels);
$notification =newstatic(sprintf('%s: %s',array_pop($parts),$exception->getMessage()),$channels);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This change assumes that the child class has the same constructor signature as its parent which is not necessarily the case.

HeahDude reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Indeed, I missed that. Should we then just add a methodexception? Like this:

/**     * @return $this     */publicfunctionexception(\Throwable$exception):self    {$parts =explode('\\',\get_class($exception));$this->subject =sprintf('%s: %s',array_pop($parts),$exception->getMessage());if (class_exists(FlattenException::class)) {$this->exception =$exceptioninstanceof FlattenException ?$exception : FlattenException::createFromThrowable($exception);        }$this->exceptionAsString =$this->computeExceptionAsString($exception);return$this;    }

chalasr reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

That sounds like a good idea. But we would need to target 6.2 with that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@andersonamuller Your suggestion seems good to me. Can you close this PR and open another one on 6.2 with the newexception() method?

@carsonbotcarsonbot changed the titleFix extensibility of Notification class[Notifier] Fix extensibility of Notification classApr 26, 2022
@OskarStarkOskarStark changed the title[Notifier] Fix extensibility of Notification class[Notifier] Fix extensibility ofNotification classJul 22, 2022
@fabpot
Copy link
Member

Closing in favor of#47038

@fabpotfabpot closed thisJul 23, 2022
fabpot added a commit that referenced this pull requestJul 23, 2022
This PR was merged into the 6.2 branch.Discussion----------[Notifier] Add Notification::exception()| Q             | A| ------------- | ---| Branch?       | 6.2| Bug fix?      | no| New feature?  | yes <!-- please update src/**/CHANGELOG.md files -->| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->| Tickets       |Fix#46172 <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->| License       | MIT| Doc PR        | -Commits-------2db50f6 [Notifier] Add Notification::exception()
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot left review comments

@derrabusderrabusderrabus requested changes

@OskarStarkOskarStarkAwaiting requested review from OskarStarkOskarStark is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@andersonamuller@fabpot@derrabus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp