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

Appearance settings

[Notifier] Add notify helper in AbstractController #42418

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

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add notify helper in abstractcontroller
  • Loading branch information
ismail1432 committed Aug 7, 2021
commit 89b1e09d47861166c574c4c302d66e5967add91b
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Messenger\Envelope;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\NotifierInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
Expand Down Expand Up @@ -103,6 +105,7 @@ public static function getSubscribedServices()
'parameter_bag' => '?'.ContainerBagInterface::class,
'message_bus' => '?'.MessageBusInterface::class,
'messenger.default_bus' => '?'.MessageBusInterface::class,
'notifier' => '?'.NotifierInterface::class,
];
}

Expand Down Expand Up @@ -456,4 +459,18 @@ protected function addLink(Request $request, LinkInterface $link): void

$request->attributes->set('_links', $linkProvider->withLink($link));
}

/**
* Send a notification via the Notifier.
*
* @param Notification $notification The $notification.
*/
protected function notify(Notification $notification): void
{
if (!$this->container->has('notifier')) {
throw new \LogicException('The Notifier is not registered in your application. Try running "composer require symfony/notifier".');
}

$this->container->get('notifier')->send($notification);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.