diff --git a/lib/Alchemy/Phrasea/Command/Setup/StaticMappingGenerator.php b/lib/Alchemy/Phrasea/Command/Setup/StaticMappingGenerator.php index 65766045c7..1ecaff8592 100644 --- a/lib/Alchemy/Phrasea/Command/Setup/StaticMappingGenerator.php +++ b/lib/Alchemy/Phrasea/Command/Setup/StaticMappingGenerator.php @@ -61,43 +61,4 @@ class StaticMappingGenerator extends Command return 0; } - - private function computeMapping($paths) - { - $paths = array_unique($paths); - - $ret = array(); - - foreach ($paths as $path) { - $ret[$path] = $this->pathsToConf($path); - } - - return $ret; - } - - private function pathsToConf($path) - { - static $n = 0; - $n++; - - return array('mount-point' => 'mp4-videos-'.$n, 'directory' => $path, 'passphrase' => \random::generatePassword(32)); - } - - private function extractPath(\appbox $appbox) - { - $paths = array(); - - foreach ($appbox->get_databoxes() as $databox) { - foreach ($databox->get_subdef_structure() as $group => $subdefs) { - if ('video' !== $group) { - continue; - } - foreach ($subdefs as $subdef) { - $paths[] = $subdef->get_path(); - } - } - } - - return array_filter(array_unique($paths)); - } } diff --git a/lib/Alchemy/Phrasea/Http/StaticFile/AbstractStaticMode.php b/lib/Alchemy/Phrasea/Http/StaticFile/AbstractStaticMode.php index eb09db5de5..a87237450c 100644 --- a/lib/Alchemy/Phrasea/Http/StaticFile/AbstractStaticMode.php +++ b/lib/Alchemy/Phrasea/Http/StaticFile/AbstractStaticMode.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Http\StaticFile; use Alchemy\Phrasea\Http\AbstractServerMode; use Alchemy\Phrasea\Http\StaticFile\Symlink\SymLinker; +use Guzzle\Http\Url; abstract class AbstractStaticMode extends AbstractServerMode { @@ -25,7 +26,22 @@ abstract class AbstractStaticMode extends AbstractServerMode parent::__construct($mapping); } - protected function ensureSymlink($pathFile) + /** + * {@inheritdoc} + */ + public function getUrl($pathFile) + { + $this->ensureSymlink($pathFile); + + return Url::factory(sprintf('%s/%s', $this->mapping['mount-point'], $this->symlinker->getSymlinkBasePath($pathFile))); + } + + /** + * Creates a link if it does not exists + * + * @param $pathFile + */ + private function ensureSymlink($pathFile) { if (false === $this->symlinker->hasSymlink($pathFile)) { $this->symlinker->symlink($pathFile); diff --git a/lib/Alchemy/Phrasea/Http/StaticFile/Apache.php b/lib/Alchemy/Phrasea/Http/StaticFile/Apache.php index 76b77df46b..f200550987 100644 --- a/lib/Alchemy/Phrasea/Http/StaticFile/Apache.php +++ b/lib/Alchemy/Phrasea/Http/StaticFile/Apache.php @@ -12,8 +12,6 @@ namespace Alchemy\Phrasea\Http\StaticFile; use Alchemy\Phrasea\Exception\InvalidArgumentException; -use Alchemy\Phrasea\Http\AbstractServerMode; -use Guzzle\Http\Url; class Apache extends AbstractStaticMode implements StaticFileModeInterface { @@ -35,16 +33,6 @@ class Apache extends AbstractStaticMode implements StaticFileModeInterface $this->mapping = $mapping; } - /** - * {@inheritdoc} - */ - public function getUrl($pathFile) - { - $this->ensureSymlink($pathFile); - - return Url::factory(sprintf('%s/%s', $this->mapping['mount-point'], $this->symlinker->getSymlinkBasePath($pathFile))); - } - /** * {@inheritdoc} */ diff --git a/lib/Alchemy/Phrasea/Http/StaticFile/Nginx.php b/lib/Alchemy/Phrasea/Http/StaticFile/Nginx.php index 8019f61ae5..a105f93336 100644 --- a/lib/Alchemy/Phrasea/Http/StaticFile/Nginx.php +++ b/lib/Alchemy/Phrasea/Http/StaticFile/Nginx.php @@ -12,8 +12,6 @@ namespace Alchemy\Phrasea\Http\StaticFile; use Alchemy\Phrasea\Exception\InvalidArgumentException; -use Alchemy\Phrasea\Http\AbstractServerMode; -use Guzzle\Http\Url; class Nginx extends AbstractStaticMode implements StaticFileModeInterface { @@ -35,16 +33,6 @@ class Nginx extends AbstractStaticMode implements StaticFileModeInterface $this->mapping = $mapping; } - /** - * {@inheritdoc} - */ - public function getUrl($pathFile) - { - $this->ensureSymlink($pathFile); - - return Url::factory(sprintf('%s/%s', $this->mapping['mount-point'], $this->symlinker->getSymlinkBasePath($pathFile))); - } - /** * {@inheritdoc} */ diff --git a/lib/Alchemy/Phrasea/Http/StaticFile/Symlink/SymLinker.php b/lib/Alchemy/Phrasea/Http/StaticFile/Symlink/SymLinker.php index f0f1f6f7c1..0c21b0bfc8 100644 --- a/lib/Alchemy/Phrasea/Http/StaticFile/Symlink/SymLinker.php +++ b/lib/Alchemy/Phrasea/Http/StaticFile/Symlink/SymLinker.php @@ -35,7 +35,7 @@ class SymLinker $app['phraseanet.thumb-symlinker-encoder'], $app['filesystem'], $app['phraseanet.registry'], - isset($app['phraseanet.configuration']['static-file']['symlink-directory']) ? $app['phraseanet.configuration']['static-file']['symlink-directory'] : null + isset($app['phraseanet.configuration']['static-file']['symlink-directory']) ? $app['phraseanet.configuration']['static-file']['symlink-directory'] : $app['root.path'] . '/symlinks' ); } @@ -43,10 +43,6 @@ class SymLinker { $this->encoder = $encoder; $this->fs = $fs; - - if (!$symlinkDir) { - throw new InvalidArgumentException("Symlink directory is not defined"); - } $this->symlinkDir = rtrim($symlinkDir, '/'); } diff --git a/lib/classes/patch/385alpha1a.php b/lib/classes/patch/385alpha1a.php index b867d7ca8f..de5550fd8f 100644 --- a/lib/classes/patch/385alpha1a.php +++ b/lib/classes/patch/385alpha1a.php @@ -55,6 +55,7 @@ class patch_385alpha1a implements patchInterface $config['static-file'] = array( 'enabled' => false, 'type' => '', + 'symlink-directory' => '', ); $app['phraseanet.configuration']->setConfig($config);