Commit e8f20492 authored by Thorsten Buss's avatar Thorsten Buss

remove LocaleUrlAware, cause locale adapter with download_url option do the...

remove LocaleUrlAware, cause locale adapter with download_url option do the same only better (add second localTestRepo for testing linker)
parent 174d5cbc
......@@ -3,9 +3,9 @@ bnrepo-test-local:
dir: /tmp/bnrepo-test
create: true
bnrepo-test-local-url-aware:
type: localUrlAware
dir: /tmp/bnrepo-test
bnrepo-test-local-2:
type: local
dir: /tmp/bnrepo-test2
create: true
bnrepo-test-s3-DISABLED:
......
<?php
/**
* User: thorsten
* Date: 28.02.14
* Time: 14:45
*/
namespace BNRepo\Repository\Adapter;
class AdapterLocalUrlAware extends AdapterLocal implements Adapter, UrlAware {
/**
* Generates a URL to the File to Download/View
*
* @param string $key
* @param string $downloadUrl URL where the File could download (Controller with Repository::download())
* @param array $options
*
* @return string Generated URL
* @throws \Gaufrette\Exception\FileNotFound when key does not exist
* @throws \RuntimeException Url cannot generated
*/
public function getUrl($key, $downloadUrl = null, $options = array()) {
// genereic downloadmanager for whole repository, set download_url in Repositories.yml
if (array_key_exists('download_url', $options)) {
return sprintf($options['download_url'], $key);
}
return 'file://'.$this->computePath($key);
}
}
\ No newline at end of file
<?php
/**
* User: thorsten
* Date: 28.02.14
* Time: 14:49
*/
namespace BNRepo\Repository;
use BNRepo\Repository\Adapter\AdapterLocalUrlAware;
class RepositoryLocalUrlAware extends RepositoryLocal {
protected function createAdapter($cfg) {
if (!isset($cfg['dir']) || empty($cfg['dir']))
$cfg['dir'] = '/';
return new AdapterLocalUrlAware($cfg['dir'], isset($cfg['create']) ? $cfg['create'] : false);
}
}
<?php
/**
* User: thorsten
* Date: 28.02.14
* Time: 14:49
*/
namespace BNRepo\Tests\Repository;
class RepositoryLocalUrlAwareTest extends RepositoryLocalTest {
protected $cfg_id = 'bnrepo-test-local-url-aware';
public function testGetUrl() {
$this->_testGetUrl($this->repo());
}
public function testGetPublicUrl() {
/** @var $repo \BNRepo\Repository\RepositoryLocalUrlAware */
$repo = $this->repo();
$repo->write('public.txt', $this->test_content, true);
$url = $repo->getUrl('public.txt');
$this->assertEquals($this->test_content, file_get_contents($url), 'check Equal Content');
$repo->delete('public.txt');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment