Skip to content

Commit

Permalink
avoided container injection
Browse files Browse the repository at this point in the history
  • Loading branch information
helios-ag committed May 8, 2014
1 parent 27432bb commit b77c7dd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
24 changes: 15 additions & 9 deletions Loader/FMElfinderLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,23 @@ class FMElfinderLoader
protected $options = array();

/**
* @var ContainerInterface $container
* @var array $parameters
*/
protected $container;
protected $parameters;

/**
* @param ContainerInterface $container
* @var Request
*/
public function __construct(ContainerInterface $container)
protected $request;

/**
* @param $parameters
* @param \Symfony\Component\HttpFoundation\Request $request
*/
public function __construct($parameters, Request $request)
{
$this->container = $container;
$this->parameters = $parameters;
$this->request = $request;
$this->options = $this->configure();
}

Expand All @@ -33,16 +40,15 @@ public function __construct(ContainerInterface $container)
*/
protected function configure()
{
$request = $this->container->get('request');
$parameters = $this->container->getParameter('fm_elfinder');

$request = $this->request;
$parameters = $this->parameters;
$options = array();
$options['debug'] = $parameters['connector']['debug'];
$options['roots'] = array();

foreach ($parameters['connector']['roots'] as $parameter) {
$path = $parameter['path'];
$driver = $this->container->has($parameter['driver']) ? $this->container->get($parameter['driver']) : null;
$driver = isset($parameter['driver']) ? $parameter['driver'] : null;
$config = array(
'driver' => $parameter['driver'],
'service' => $driver,
Expand Down
7 changes: 4 additions & 3 deletions Resources/config/elfinder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
</parameters>

<services>
<service id="elfinder_loader" class="%elfinder.loader%">
<argument type="service" id="service_container" />
<service id="elfinder_loader" class="%elfinder.loader%" scope="request">
<argument>%fm_elfinder%</argument>
<argument type="service" id="request"/>
</service>

<service id="twig.extension.fm_tinymce_init" class="FM\ElfinderBundle\Twig\Extension\FMElfinderTinymceExtension">
<argument type="service" id="service_container"></argument>
<argument type="service" id="twig"/>
<tag name="twig.extension" alias="fm_tinymce_init" />
</service>
</services>
Expand Down
16 changes: 7 additions & 9 deletions Twig/Extension/FMElfinderTinymceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,23 @@

namespace FM\ElfinderBundle\Twig\Extension;

use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Class FMElfinderTinymceExtension
* @package FM\ElfinderBundle\Twig\Extension
*/
class FMElfinderTinymceExtension extends \Twig_Extension
{
/**
* @var \Symfony\Component\DependencyInjection\ContainerInterface
* @var \Twig_Environment
*/
protected $container;
protected $twig;

/**
* @param ContainerInterface $container
* @param \Twig_Environment $twig
*/
public function __construct(ContainerInterface $container)
public function __construct(\Twig_Environment $twig)
{
$this->container = $container;
$this->twig = $twig;
}

/**
Expand All @@ -41,15 +39,15 @@ public function getFunctions()
*/
public function tinymce()
{
return $this->container->get('templating')->render('FMElfinderBundle:Elfinder/helper:_tinymce.html.twig');
return $this->twig->render('FMElfinderBundle:Elfinder/helper:_tinymce.html.twig');
}

/**
* @return mixed
*/
public function tinymce4()
{
return $this->container->get('templating')->render('FMElfinderBundle:Elfinder/helper:_tinymce4.html.twig');
return $this->twig->render('FMElfinderBundle:Elfinder/helper:_tinymce4.html.twig');
}

/**
Expand Down

0 comments on commit b77c7dd

Please sign in to comment.