apps/user_ldap/lib/Notification/Notifier.php
/**
	 * @param INotification $notification
	 * @param string $languageCode The code of the language that should be used to prepare the notification
	 * @return INotification
	 * @throws \InvalidArgumentException When the notification was not prepared by a notifier
	 */
@param INotification $notification
@param string $languageCode The code of the language that should be used to prepare the notification
@return INotification
@throws \InvalidArgumentException When the notification was not prepared by a notifier
@param INotification $notification @param string $languageCode The code of the language that should be used to prepare the notification @return INotification @throws \ InvalidArgumentException When the notification was not prepared by a notifier
public function prepare(INotification $notification, $languageCode) {
		if ($notification->getApp() !== 'user_ldap') {
			throw new \InvalidArgumentException();
		}
		$l = $this->l10nFactory->get('user_ldap', $languageCode);
		switch ($notification->getSubject()) {
			case 'pwd_exp_warn_days':
				$params = $notification->getSubjectParameters();
				$days = (int) $params[0];
				if ($days === 2) {
					$notification->setParsedSubject($l->t('Your password will expire tomorrow.', $days));
				} else if ($days === 1) {
					$notification->setParsedSubject($l->t('Your password will expire today.', $days));
				} else {
					$notification->setParsedSubject($l->n(
						'Your password will expire within %n day.',
						'Your password will expire within %n days.',
						$days
					));
				}
				return $notification;
			default:
				throw new \InvalidArgumentException();
		}
	}
public function prepare ( INotification $ notification , $ languageCode ) { if ( $ notification -> getApp ( ) !== 'user_ldap' ) { throw new \ InvalidArgumentException ( ) ; } $ l = $ this -> l10nFactory -> get ( 'user_ldap' , $ languageCode ) ; switch ( $ notification -> getSubject ( ) ) { case 'pwd_exp_warn_days' : $ params = $ notification -> getSubjectParameters ( ) ; $ days = ( int ) $ params [ 0 ] ; if ( $ days === 2 ) { $ notification -> setParsedSubject ( $ l -> t ( 'Your password will expire tomorrow.' , $ days ) ) ; } else if ( $ days === 1 ) { $ notification -> setParsedSubject ( $ l -> t ( 'Your password will expire today.' , $ days ) ) ; } else { $ notification -> setParsedSubject ( $ l -> n ( 'Your password will expire within %n day.' , 'Your password will expire within %n days.' , $ days ) ) ; } return $ notification ; default : throw new \ InvalidArgumentException ( ) ; } }
@param INotification $notification
 @param string $languageCode The code of the language that should be used to prepare the notification
 @return INotification
 @throws \InvalidArgumentException When the notification was not prepared by a notifier
@param INotification $notification @param string $languageCode The code of the language that should be used to prepare the notification @return INotification @throws \ InvalidArgumentException When the notification was not prepared by a notifier
// Not my app => throw // Read the language from the notification // Deal with known subjects // Unknown subject => Unknown notification => throw