Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kivi/1677586 to your computer and use it in GitHub Desktop.
Save kivi/1677586 to your computer and use it in GitHub Desktop.
services:
notification:
class: Itembase\CoreBundle\Services\NotificationService
arguments: [@mailer, @doctrine.orm.entity_manager, @templating]
// as you can see we are injecting @mailer, @doctrine.orm.entity_manager, @templating
// You'll find this again in NotificationService constructor.
// that is a nice way to pass services arround.
// this command uses the Notification Service
class ActivityStreamUpdaterCommand extends ContainerAwareCommand
{
private $silentMode;
private function sendOutNotification($action, $payload, $user, $actorIdentifier, $actorName)
{
if ($user->getUsername() != $actorIdentifier) {
// get a instance of NotificationService
$notifier = $this->getContainer()->get('notification');
// now use the NotificationServer
$notifier->sendNotification(
$user, // Receiver
namespace Itembase\CoreBundle\Services;
class NotificationService
{
private $mailer;
private $em;
private $templating;
// constructor with params, that will be injected.
public function __construct(\Swift_Mailer $mailer, EntityManager $em, EngineInterface $templating)
{
$this->em = $em;
$this->mailer = $mailer;
$this->templating = $templating;
}
<?
// this command uses the Notification Service
class ActivityStreamUpdaterCommand extends ContainerAwareCommand
{
private $silentMode;
private function sendOutNotification($action, $payload, $user, $actorIdentifier, $actorName)
{
if ($user->getUsername() != $actorIdentifier) {
// get a instance of NotificationService
$notifier = $this->getContainer()->get('notification');
// now use the NotificationServer
$notifier->sendNotification(
$user, // Receiver
<?
namespace Itembase\CoreBundle\Services;
class NotificationService
{
private $mailer;
private $em;
private $templating;
// constructor with params, that will be injected.
public function __construct(\Swift_Mailer $mailer, EntityManager $em, EngineInterface $templating)
{
$this->em = $em;
$this->mailer = $mailer;
$this->templating = $templating;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment