Skip to content

Instantly share code, notes, and snippets.

@frastel
Created November 26, 2012 16:11
Show Gist options
  • Save frastel/4149029 to your computer and use it in GitHub Desktop.
Save frastel/4149029 to your computer and use it in GitHub Desktop.
Don't pull your dependencies 1
<?php
// src/frastel/BlogPlaygroundBundle/Container/DependencyPuller.php
namespace frastel\BlogPlaygroundBundle\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
class DependencyPuller
{
private $container;
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
public function doSomething()
{
$result = false;
// do some fency stuff here
$result = true;
$this->container->get('logger')->debug('before sending mail');
$message = \Swift_Message::newInstance()
->setSubject('Some subject')
->setTo('test@example.com')
->setBody('Some body');
$this->container->get('mailer')->send($message);
$this->container->get('logger')->debug('after sending mail');
return $result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment