mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Reduce duplication in H264MappingGenerator
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Databox\DataboxPathExtractor;
|
||||
use Alchemy\Phrasea\Http\H264PseudoStreaming\H264Factory;
|
||||
use Alchemy\Phrasea\Model\Manipulator\TokenManipulator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -36,7 +37,8 @@ class H264MappingGenerator extends Command
|
||||
*/
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$paths = $this->extractPath($this->container->getApplicationBox());
|
||||
$extractor = new DataboxPathExtractor($this->container->getApplicationBox());
|
||||
$paths = $extractor->extractPaths();
|
||||
foreach ($paths as $path) {
|
||||
$this->container['filesystem']->mkdir($path);
|
||||
}
|
||||
@@ -95,22 +97,4 @@ class H264MappingGenerator extends Command
|
||||
|
||||
return ['mount-point' => 'mp4-videos-'.$n, 'directory' => $path, 'passphrase' => $this->container['random.low']->generateString(32, TokenManipulator::LETTERS_AND_NUMBERS)];
|
||||
}
|
||||
|
||||
private function extractPath(\appbox $appbox)
|
||||
{
|
||||
$paths = [];
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@@ -12,6 +12,7 @@
|
||||
namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Databox\DataboxPathExtractor;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -35,7 +36,8 @@ class XSendFileMappingGenerator extends Command
|
||||
*/
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$paths = $this->extractPath($this->container->getApplicationBox());
|
||||
$extractor = new DataboxPathExtractor($this->container->getApplicationBox());
|
||||
$paths = $extractor->extractPaths();
|
||||
foreach ($paths as $path) {
|
||||
$this->container['filesystem']->mkdir($path);
|
||||
}
|
||||
@@ -84,20 +86,4 @@ class XSendFileMappingGenerator extends Command
|
||||
|
||||
return ['mount-point' => 'protected_dir_'.$n, 'directory' => $path];
|
||||
}
|
||||
|
||||
private function extractPath(\appbox $appbox)
|
||||
{
|
||||
$paths = [];
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
$paths[] = (string) $databox->get_sxml_structure()->path;
|
||||
foreach ($databox->get_subdef_structure() as $group => $subdefs) {
|
||||
foreach ($subdefs as $subdef) {
|
||||
$paths[] = $subdef->get_path();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array_filter(array_unique($paths));
|
||||
}
|
||||
}
|
||||
|
37
lib/Alchemy/Phrasea/Databox/DataboxPathExtractor.php
Normal file
37
lib/Alchemy/Phrasea/Databox/DataboxPathExtractor.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2016 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Databox;
|
||||
|
||||
class DataboxPathExtractor
|
||||
{
|
||||
/**
|
||||
* @var \appbox
|
||||
*/
|
||||
private $appbox;
|
||||
|
||||
public function __construct(\appbox $appbox)
|
||||
{
|
||||
$this->appbox = $appbox;
|
||||
}
|
||||
|
||||
public function extractPaths()
|
||||
{
|
||||
$paths = [];
|
||||
|
||||
foreach ($this->appbox->get_databoxes() as $databox) {
|
||||
foreach ($databox->get_subdef_structure()->getSubdefGroup('video') as $subdef) {
|
||||
$paths[] = $subdef->get_path();
|
||||
}
|
||||
}
|
||||
|
||||
return array_filter(array_unique($paths));
|
||||
}
|
||||
}
|
@@ -994,8 +994,7 @@ class databox extends base implements ThumbnailedElement
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return databox_subdefsStructure
|
||||
* @return databox_subdefsStructure|databox_subdef[][]
|
||||
*/
|
||||
public function get_subdef_structure()
|
||||
{
|
||||
|
@@ -44,9 +44,7 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param databox $databox
|
||||
* @return Array
|
||||
*/
|
||||
public function __construct(databox $databox, TranslatorInterface $translator)
|
||||
{
|
||||
@@ -54,8 +52,6 @@ class databox_subdefsStructure implements IteratorAggregate, Countable
|
||||
$this->translator = $translator;
|
||||
|
||||
$this->load_subdefs();
|
||||
|
||||
return $this->AvSubdefs;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user