title: Access to user name in config file for Symfony
body: <p>I'm using <a href="https://github.com/helios-ag/FMElfinderBundle" rel="nofollow noreferrer">FMElfinder</a> in association with TinyMCE for managing the assets  (images, pdf ...) of the users (managed with FOSUSerBundle)</p>
  
  <p>I've seen that this tool can handle <a href="https://github.com/helios-ag/FMElfinderBundle#use-multiple-upload-folder-by-instance" rel="nofollow noreferrer">multiple root</a> folder, but in my case, it isn't quite usable : i would like to have a root folder for each user.</p>
  
  <p>In the configuration file app/config/config.yml, there is the root path(s) defined :</p>
  
  <pre><code>fm_elfinder:
      instances:
          default:
              locale: %locale% 
              ...
              connector:
                  roots:
                      uploads:
                          driver: LocalFileSystem
                          path: uploads/data
  </code></pre>
  
  <p>I was thining about "simply" changing the path to something like :</p>
  
  <pre><code>path: uploads/data/{the_username}
  </code></pre>
  
  <p>where the username would be the username of the currently logged user</p>
  
  <p>In a controller i can do </p>
  
  <pre><code>$user = $this-&gt;get('security.token_storage')-&gt;getToken()-&gt;getUser();
  $username = $user-&gt;getUsername();
  </code></pre>
  
  <p>But <strong>i don't know if it's possible (and if so, how) to access specifically the username of the logged user into a config file</strong></p>
  
  <p>Thank you if you have any suggestion</p>
  
  <p>=================[EDIT] ==========================================</p>
  
  <p>I've use the <a href="https://github.com/helios-ag/FMElfinderBundle/blob/master/Resources/doc/advanced-configuration.md#custom-configuration-provider" rel="nofollow noreferrer">override of configuration</a>. I think i followed the steps, but i haven't managed to make it work :</p>
  
  <p>1 - Create the class</p>
  
  <pre><code>use FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface;
  use Symfony\Component\DependencyInjection\ContainerInterface;
  class ElfinderConfigurator implements ElFinderConfigurationProviderInterface
  {
      protected $container;
      protected $options;
  
      /**
       * @param ContainerInterface                             $container
       */
      public function __construct($options, ContainerInterface $container)
      {
          $this-&gt;container    = $container;
          $this-&gt;storage      = $container-&gt;get('security.token_storage');
          $this-&gt;options      = $options;
      }
  
      /**
       * @param $instance
       *
       * @return array
       */
      public function getConfiguration($instance)
      {
          //retrieve basepath
          $basepath_abs = $this-&gt;container-&gt;get('kernel')-&gt;getRootDir()."/../web/uploads";
          $basepath = "uploads/data";
  
          //define path for user
          $userid = $this-&gt;storage-&gt;getToken()-&gt;getUser()-&gt;getId();
          $root = $basepath.'/'.$userid;
          $this-&gt;options['instances']['default']['connector']['roots']['uploads']['path'] = $root.'/root';
          $this-&gt;options['instances']['default']['connector']['roots']['uploads']['upload_max_size'] = '2M';
          $option = [
              'corsSupport' =&gt; false,
              'roots' =&gt; $this-&gt;options['instances']['default']['connector']['roots'],
          ];
  
          $root_abs = $basepath_abs.'/data/'.$userid;
          //creates dir if not available
          if (!is_dir($root_abs)) {
              mkdir($root_abs.'/root', 0775, true);
          }
  
          return $option;
      }
  }
  </code></pre>
  
  <p>2 - Set my service :</p>
  
  <pre><code>myvendor.mybundle.elfinder_configurator:
      class:        Myvendor\Mybundle\Services\ElfinderConfigurator
      arguments:    ["%fm_elfinder%", "@service_container"]
  </code></pre>
  
  <p>3 - Call the service in app/config/config.yml</p>
  
  <pre><code>fm_elfinder:
      configuration_provider: myvendor.mybundle.elfinder_configurator
      ...
  </code></pre>
  
  <p>It works partially : When i open the elfinde, the directory are correctly created if they don't exists. But there must be <strong>a path problem</strong>, and i'm not sure it's <strong>well overriden</strong> because : 
  - The thumbs are not displayed in elfinder
  - When i add the image to the editor, i don't have the correct path of the image, i have : </p>
  
  <pre><code>//app_dev.php/efconnect?cmd=file&amp;target=l1_Q2FwdHVyZSBkJ8OpY3JhbiBkZSAyMDE2LTAxLTI0IDE0OjM2OjI0LnBuZw
  </code></pre>
  
  <p>instead of the actual path of the image (if i don't use the override, the tool works and gives me this path)</p>
  
  <pre><code>../../../../uploads/data/1/root/img1.png
  </code></pre>
  
  <p>and no image is displayed.</p>
  
  <p>Also, if i look in the js console for the </p>
  
  <pre><code>efconnect?cmd=open&amp;target=&amp;init=1&amp;tree=1&amp;_=1469377765664
  </code></pre>
  
  <p>I see that uplMaxSize is 200M, </p>
  
  <p><a href="https://i.stack.imgur.com/VwUvL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VwUvL.png" alt="enter image description here"></a></p>
  
  <p><strong>in any case, there is no js error in the console</strong></p>