[TYPO3-mvc] Where is the right place for methods like sendEmailAfterNewObjectIsSaved() in your extbase extension?
Bastian Waidelich
bastian at typo3.org
Mon Jun 25 17:22:35 CEST 2012
Roland wrote:
Hi,
> > Instead you could create a NotificationService
>
> i guess this should then implement t3lib_Singleton
Yes, makes sense!
> must be instantiated in my domain model object
No. Usually sending notification emails is not part of your domain.
Instead you could trigger it from your controller (but it should be a
one-liner there). E.G.:
$this->beerRepository->add($newBeer);
$this->flashMessageContainer->add('Yummy, beer!');
$this->notificationService->sendBeerNotification($newBeer);
Or, if the notification service is just a thin wrapper like [1]:
$this->notificationService->sendTemplateEmail($recipient, $sender, 'New
Beer', 'BeerNotificationTemplate', array('beer' => $newBeer));
> should it be instantiated via dependency injection?
That doesn't really matter. But yes :)
[1]
http://forge.typo3.org/projects/typo3v4-mvc/wiki/How_to_use_the_Fluid_Standalone_view_to_render_template_based_emails
--
Bastian Waidelich
TYPO3 Core Team Member
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-project-typo3v4mvc
mailing list