Skip to content

Commit

Permalink
inject param instead of container
Browse files Browse the repository at this point in the history
  • Loading branch information
codebach committed May 5, 2016
1 parent 72585de commit 750db74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ services:
# PianoSolo Weather Twig Extension Service
pianosolo.weather.twig.weather:
class: PianoSolo\WeatherBundle\Twig\WeatherExtension
arguments: ["@pianosolo.weather","@service_container"]
arguments: ["@pianosolo.weather","%pianosolo.weather.options.download_csv%"]
tags:
- { name:twig.extension }
16 changes: 6 additions & 10 deletions Twig/WeatherExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ class WeatherExtension extends \Twig_Extension
private $weatherFactory;

/**
* @var ContainerInterface
* @var boolean
*/
private $container;
private $downloadEnabled;

/**
* @param WeatherFactory $weatherFactory
*/
public function __construct(WeatherFactory $weatherFactory, ContainerInterface $container)
public function __construct(WeatherFactory $weatherFactory, $downloadEnabled)
{
$this->weatherFactory = $weatherFactory;
$this->container = $container;
$this->downloadEnabled = $downloadEnabled;
}

public function getFunctions()
Expand Down Expand Up @@ -57,12 +57,10 @@ public function weather(\Twig_Environment $environment, $city)
{
$weathers = $this->weatherFactory->getWeatherObject($city);

$downloadEnabled = $this->container->getParameter('pianosolo.weather.options.download_csv');

return $environment->render('PianoSoloWeatherBundle:Weather:weather.html.twig', array(
'city' => $city,
'weathers' => $weathers,
'downloadEnabled' => $downloadEnabled
'downloadEnabled' => $this->downloadEnabled
));
}

Expand All @@ -78,12 +76,10 @@ public function forecast(\Twig_Environment $environment, $city, $days = '3')
{
$weathers = $this->weatherFactory->getForecastObject($city, $days);

$downloadEnabled = $this->container->getParameter('pianosolo.weather.options.download_csv');

return $environment->render('PianoSoloWeatherBundle:Weather:weather.html.twig', array(
'city' => $city,
'weathers' => $weathers,
'downloadEnabled' => $downloadEnabled
'downloadEnabled' => $this->downloadEnabled
));
}

Expand Down

0 comments on commit 750db74

Please sign in to comment.