Skip to content

Commit

Permalink
Merge pull request #47 from mmoreram/feature/remove-dic-dependency
Browse files Browse the repository at this point in the history
Removed all DIC dependency in twig extension and DataCollector
  • Loading branch information
raulfraile committed Jul 3, 2014
2 parents fd7e137 + d2b83a6 commit f668d76
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 27 deletions.
17 changes: 9 additions & 8 deletions DataCollector/LadybugDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,36 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Ladybug\Dumper;

/**
* The LadybugDataCollector class.
*/
class LadybugDataCollector extends DataCollector
{
/**
* @var Dumper
*
* @var ContainerInterface $container The Symfony DIC.
* Ladybug Dumper
*/
private $container;
private $ladybug;

/**
* Main constructor.
* Main constructor
*
* @param ContainerInterface $container
* @param Dumper $ladybug Ladybyg Dumper
*/
public function __construct(ContainerInterface $container)
public function __construct(Dumper $ladybug)
{
$this->container = $container;
$this->ladybug = $ladybug;
}

/**
* Log an info.
*/
public function log()
{
$ladybug = $this->container->get('ladybug.dumper');
$content = call_user_func_array(array($ladybug,'dump'), func_get_args());
$content = call_user_func_array(array($this->ladybug,'dump'), func_get_args());

$trace = debug_backtrace();

Expand Down
4 changes: 2 additions & 2 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

<service id="ladybug.twig.extension" class="RaulFraile\Bundle\LadybugBundle\Twig\Extension\LadybugExtension" public="false">
<tag name="twig.extension" />
<argument type="service" id="service_container"></argument>
<argument type="service" id="ladybug.dumper"></argument>
</service>

<service id="data_collector.ladybug_data_collector" class="RaulFraile\Bundle\LadybugBundle\DataCollector\LadybugDataCollector">
<argument type="service" id="service_container" />
<argument type="service" id="ladybug.dumper" />
<tag name="data_collector" template="RaulFraileLadybugBundle:Collector:ladybug" id="ladybug" />
</service>

Expand Down
26 changes: 9 additions & 17 deletions Twig/Extension/LadybugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,28 @@
namespace RaulFraile\Bundle\LadybugBundle\Twig\Extension;

use Symfony\Component\DependencyInjection\ContainerInterface;
use Ladybug\Dumper;

/**
* Twig extension for the bundle.
*/
class LadybugExtension extends \Twig_Extension
{
/**
* @var ContainerInterface $container The Symfony2 DIC.
*/
private $container;

/**
* Main constructor.
* @var Dumper
*
* @param ContainerInterface $container
* Ladybug Dumper
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
private $ladybug;

/**
* Getter.
* Main constructor
*
* @return ContainerInterface
* @param Dumper $ladybug Ladybyg Dumper
*/
public function getContainer()
public function __construct(Dumper $ladybug)
{
return $this->container;
$this->ladybug = $ladybug;
}

/**
Expand Down Expand Up @@ -67,8 +60,7 @@ public function getFunctions()
*/
public function ladybug_dump()
{
$ladybug = $this->container->get('ladybug.dumper');
$html = call_user_func_array(array($ladybug, 'dump'), func_get_args());
$html = call_user_func_array(array($this->ladybug, 'dump'), func_get_args());

return $html;
}
Expand Down

0 comments on commit f668d76

Please sign in to comment.