protected function setFiles($key, $files)
 {
     $filesInDir = array('dir' => null, 'dir/' => null);
     foreach ($files as $file => $content) {
         $filesInDir['dir/' . $file] = $content;
     }
     StreamWrapper::getFilesystemMap()->get($key)->getAdapter()->setFiles($filesInDir);
 }
Example #2
0
 function registerStreamWrapper($filesystem = null)
 {
     if (!empty($filesystem)) {
         $map = \Gaufrette\StreamWrapper::getFilesystemMap();
         $map->set(self::$_stream_name, $filesystem);
         \Gaufrette\StreamWrapper::register();
     }
 }
 public function setUp()
 {
     $adapter = new Adapter(sys_get_temp_dir(), true);
     $filesystem = new GaufretteFilesystem($adapter);
     $map = StreamWrapper::getFilesystemMap();
     $map->set('oneup', $filesystem);
     StreamWrapper::register();
     $this->storage = new GaufretteStorage($filesystem, 100000);
     $this->path = 'oneup_test_tmp';
     mkdir(sys_get_temp_dir() . '/' . $this->path);
     $this->basename = 'test_file.txt';
     $this->pathname = $this->path . '/' . $this->basename;
     $this->extension = 'txt';
     $this->size = 9;
     //something = 9 bytes
     $this->mimeType = 'text/plain';
     file_put_contents(sys_get_temp_dir() . '/' . $this->pathname, 'something');
     $this->file = new GaufretteFile(new File($this->pathname, $filesystem), $filesystem, 'gaufrette://oneup/');
 }
 public function boot()
 {
     parent::boot();
     if (!$this->container->hasParameter('knp_gaufrette.stream_wrapper.protocol') || !$this->container->hasParameter('knp_gaufrette.stream_wrapper.filesystems')) {
         return;
     }
     StreamWrapper::register($this->container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
     $wrapperFsMap = StreamWrapper::getFilesystemMap();
     $fileSystems = $this->container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
     /*
      * If there are no filesystems configured to be wrapped,
      * all filesystems within the map will be wrapped.
      */
     if (empty($fileSystems)) {
         $fileSystems = $this->container->get('knp_gaufrette.filesystem_map');
         foreach ($fileSystems as $domain => $fileSystem) {
             $wrapperFsMap->set($domain, $fileSystem);
         }
     } else {
         foreach ($fileSystems as $domain => $fileSystem) {
             $wrapperFsMap->set($domain, $this->container->get('knp_gaufrette.filesystem_map')->get($fileSystem));
         }
     }
 }
Example #5
0
 protected function registerLocalFilesystemInStream()
 {
     $filesystemMap = StreamWrapper::getFilesystemMap();
     $filesystemMap->set('filestream', $this->filesystem);
     StreamWrapper::register();
 }
 /**
  * @test
  * @functional
  */
 public function shouldAllowToDefineFileSystemsWithoutDomain()
 {
     $kernel = new TestKernel('wrapper_3', false);
     $kernel->boot();
     $container = $kernel->getContainer();
     $fileSystems = $container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
     $this->assertTrue($container->hasParameter('knp_gaufrette.stream_wrapper.protocol'));
     $this->assertEquals('tada', $container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
     $this->assertEquals(array('cache' => 'cache', 'ftp' => 'ftp'), $fileSystems);
     $wrapperFsMap = StreamWrapper::getFilesystemMap();
     foreach ($fileSystems as $key => $fs) {
         $this->assertTrue($wrapperFsMap->has($key));
     }
 }