Commit d43554db authored by dj3c1t's avatar dj3c1t

rootDir avec parameter web_dir

parent f3b287b7
......@@ -18,7 +18,9 @@ class SourceCache {
public function __construct(Container $container) {
$this->container = $container;
$this->rootDir = dirname($this->container->get('kernel')->getRootDir())."/web";
$this->rootDir =
dirname($this->container->get('kernel')->getRootDir())
."/".$this->container->getParameter('web_dir');
$this->xmlDir = 'medias/xml';
}
......
......@@ -11,8 +11,18 @@ class SourceWaveform {
protected $container;
protected $rootDir;
protected $mediaRootDir;
protected $waveformDir;
public function __construct(Container $container) {
$this->container = $container;
$upload_manager = $this->container->get('dj3c1t_jq_file_upload.upload_manager');
$this->rootDir =
dirname($this->container->get('kernel')->getRootDir())
."/".$this->container->getParameter('web_dir');
$this->mediaRootDir = $upload_manager->getMediaRootDir();
$this->waveformDir = "waveforms";
}
public function getAudioFileMimeTypes() {
......@@ -38,10 +48,7 @@ class SourceWaveform {
}
public function getMediasDir() {
$upload_manager = $this->container->get('dj3c1t_jq_file_upload.upload_manager');
return
dirname($this->container->get('kernel')->getRootDir())."/web"
."/".$upload_manager->getMediaRootDir()."/";
return $this->rootDir."/".$this->mediaRootDir."/";
}
public function updateWaveform(Source $source, $forceUpdate = false) {
......@@ -70,7 +77,7 @@ class SourceWaveform {
&& ($this->isAudioMimeType($media->getMimeType()))
) {
$this->makeWaveformsDir();
$pngFile = "waveforms/".$source->getId().".png";
$pngFile = $this->waveformDir."/".$source->getId().".png";
$sw->audioToPng(
$mediasDir.$media->getName(),
$mediasDir.$pngFile,
......@@ -94,11 +101,19 @@ class SourceWaveform {
}
public function makeWaveformsDir() {
$mediasDir = $this->getMediasDir();
if(!is_dir($mediasDir."waveforms")) {
@mkdir($mediasDir."waveforms");
if(!is_dir($mediasDir."waveforms")) {
throw new \Exception("unable to make waveforms dir");
$current_dir = $this->rootDir;
$path = explode("/", $this->mediaRootDir."/".$this->waveformDir);
foreach($path as $dir) {
if(!$dir) {
continue;
}
$current_dir .= "/".$dir;
if(is_dir($current_dir)) {
continue;
}
@mkdir($current_dir);
if(!is_dir($current_dir)) {
throw new \Exception("unable to make ".$this->waveformDir." dir");
}
}
}
......
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