Skip to content

Commit

Permalink
Merge pull request #83 from helios-ag/volumedriver_service
Browse files Browse the repository at this point in the history
restored ability to use services as drivers
  • Loading branch information
helios-ag committed Nov 9, 2014
2 parents eef1cc0 + 574ed84 commit 95c5159
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Bridge/ElFinderBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FM\ElfinderBundle\Bridge;

use FM\ElFinderPHP\ElFinder;
use FM\ElFinderPHP\Driver\ElFinderVolumeDriver;

/**
* Class ElFinderBridge
Expand All @@ -21,7 +22,7 @@ protected function mountVolumes($opts)
$volume = null;
if (isset($o['service'])) {
$driver = $o['service'];
if (is_object($driver) && $driver instanceof \FM\ElFinderPHP\Driver\ElFinderVolumeDriver) {
if (is_object($driver) && $driver instanceof ElFinderVolumeDriver) {
$volume = $driver;
unset($opts['roots'][$i]);
}
Expand Down
11 changes: 9 additions & 2 deletions Configuration/ElFinderConfigurationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FM\ElfinderBundle\Configuration;

use FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;

Expand All @@ -27,14 +28,20 @@ class ElFinderConfigurationReader implements ElFinderConfigurationProviderInterf
*/
protected $requestStack;

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

/**
* @param $parameters
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
*/
public function __construct($parameters, RequestStack $requestStack)
public function __construct($parameters, RequestStack $requestStack, ContainerInterface $container)
{
$this->parameters = $parameters;
$this->requestStack = $requestStack;
$this->container = $container;
}

/**
Expand All @@ -53,7 +60,7 @@ public function getConfiguration($instance)
foreach ($parameters['connector']['roots'] as $parameter) {
$path = $parameter['path'];

$driver = isset($parameter['driver']) ? $parameter['driver'] : null;
$driver = $this->container->has($parameter['driver']) ? $this->container->get($parameter['driver']) : null;

$driverOptions = array(
'driver' => $parameter['driver'],
Expand Down
8 changes: 6 additions & 2 deletions Controller/ElFinderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class ElFinderController extends Controller

/**
* Renders Elfinder
* @param string $instance
* @param Request $request
* @param string $instance
* @return Response
*/
public function showAction(Request $request, $instance)
Expand All @@ -32,13 +33,15 @@ public function showAction(Request $request, $instance)
/**
* @param $parameters
* @param $instance
* @param null $formTypeId
* @return array
*/
private function selectEditor($parameters, $instance, $formTypeId = null)
{
$editor = $parameters['editor'];
$locale = $parameters['locale'] ?: $this->container->getParameter('locale');
$fullscreen = $parameters['fullscreen'];
$relativePath = $parameters['relative_path'];
$includeAssets = $parameters['include_assets'];
$compression = $parameters['compression'];
$prefix = ($compression ? '/compressed' : '');
Expand Down Expand Up @@ -78,7 +81,8 @@ private function selectEditor($parameters, $instance, $formTypeId = null)
'fullscreen' => $fullscreen,
'includeAssets' => $includeAssets,
'instance' => $instance,
'id'=>$formTypeId
'id' => $formTypeId,
'relative_path' => $relativePath
);
return $result;
default:
Expand Down
6 changes: 1 addition & 5 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getConfigTreeBuilder()
->booleanNode('include_assets')->defaultTrue()->end()
->scalarNode('tinymce_popup_path')->defaultValue('')->end()
->booleanNode('enableUserIntegration')->defaultFalse()->end()
->booleanNode('relative_path')->defaultTrue()->end()
->arrayNode('connector')
->addDefaultsIfNotSet()
->children()
Expand All @@ -50,10 +51,6 @@ public function getConfigTreeBuilder()
->children()
->scalarNode('driver')
->isRequired()
->validate()
->ifNotInArray(array('LocalFileSystem', 'FTP', 'FTPIIS', 'Dropbox', 'S3'))
->thenInvalid('Invalid filesystem driver "%s"')
->end()
->defaultValue('LocalFileSystem')->end()
->arrayNode('disabled')
->prototype('scalar')->end()
Expand All @@ -65,7 +62,6 @@ public function getConfigTreeBuilder()
->scalarNode('alias')->defaultValue('')->end()
->integerNode('treeDeep')->defaultValue(0)->end()
->scalarNode('accessControl')->defaultNull()->end()
->booleanNode('enableUserIntegration')->defaultFalse()->end()
->arrayNode('upload_allow')
->prototype('scalar')->end()
->defaultValue(array('image'))
Expand Down
1 change: 1 addition & 0 deletions Resources/config/elfinder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<service id="fm_elfinder.configurator.default" class="%fm_elfinder.configurator%">
<argument>%fm_elfinder%</argument>
<argument type="service" id="request_stack"/>
<argument type="service" id="service_container"/>
</service>
<service id="fm_elfinder.loader" class="FM\ElfinderBundle\Loader\ElFinderLoader">
<argument type="service" id="fm_elfinder.configurator"/>
Expand Down
6 changes: 5 additions & 1 deletion Resources/views/Elfinder/elfinder_type.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
url : '{{path('ef_connect', { 'instance': instance } )}}',
lang : '{{locale}}',
getFileCallback: function(file) {
window.opener.setValue(file.path, "{{ id }}");
{% if relative_path %}
window.opener.setValue(file.path, "{{ id }}");
{% else %}
window.opener.setValue(file.url, "{{ id }}");
{% endif %}
window.close();
}
});
Expand Down

0 comments on commit 95c5159

Please sign in to comment.