Skip to content

Instantly share code, notes, and snippets.

@helios-ag
Created July 11, 2015 16:26
Show Gist options
  • Save helios-ag/dcb2ed44e2317a5e4193 to your computer and use it in GitHub Desktop.
Save helios-ag/dcb2ed44e2317a5e4193 to your computer and use it in GitHub Desktop.
ConfigurationReader short
<?php
namespace AppBundle\Service;
use FM\ElfinderBundle\Configuration\ElFinderConfigurationReader;
use FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RequestStack;
class ConfigurationReader extends ElFinderConfigurationReader
{
/**
* @param $instance
* @return array
*/
public function getConfiguration($instance)
{
...
foreach ($parameters['connector']['roots'] as $parameter) {
$path = $parameter['path'];
$homeFolder = $this->container->get('security.token_storage')->getToken()->getUser()->getUsername();
$driver = $this->container->has($parameter['driver']) ? $this->container->get($parameter['driver']) : null;
$driverOptions = array(
...
'path' => $path .'/'. $homeFolder,
...
);
if(!$parameter['show_hidden']) {
$driverOptions['accessControl'] = array($this, 'access');
};
if($parameter['driver'] == 'Flysystem') {
$driverOptions['filesystem'] = $filesystem;
}
$options['roots'][] = array_merge($driverOptions, $this->configureDriver($parameter));
}
return $options;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment