Created
July 11, 2012 12:45
-
-
Save wpottier/3090164 to your computer and use it in GitHub Desktop.
BaseMailer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Mon\Site\BlogBundle\Mailer; | |
class BaseMailer { | |
protected $mailer; | |
protected $container; | |
public function __construct(\Symfony\Component\DependencyInjection\Container $container) { | |
$this->container = $container; | |
} | |
protected function getMailer() { | |
return $this->container->get('mailer'); | |
} | |
/** | |
* @return \Symfony\Bundle\FrameworkBundle\Routing\Router | |
*/ | |
protected function getRouter() { | |
return $this->container->get('router'); | |
} | |
/** | |
* Generates a URL from the given parameters. | |
* | |
* @param string $route The name of the route | |
* @param mixed $parameters An array of parameters | |
* @param Boolean $absolute Whether to generate an absolute URL | |
* | |
* @return string The generated URL | |
*/ | |
protected function generateUrl($route, $parameters = array(), $absolute = false) { | |
return $this->getRouter()->generate($route, $parameters, $absolute); | |
} | |
protected function getSenderEmail() { | |
return '[email protected]'; | |
} | |
protected function send($message) { | |
$this->container->get('mailer')->send($message); | |
} | |
/** | |
* Returns a rendered view. | |
* | |
* @param string $view The view name | |
* @param array $parameters An array of parameters to pass to the view | |
* | |
* @return string The renderer view | |
*/ | |
public function renderView($view, array $parameters = array()) { | |
return $this->container->get('templating')->render($view, $parameters); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment