mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Merge pull request #1091 from nlegoff/yeah-yeah-yeah
[3.8.6][PHRAS-136] Add static file mode to serve thumbnails
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class StaticConfigurationDumper extends Command
|
||||
{
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct('static-file:dump-configuration');
|
||||
|
||||
$this->setDescription('Dump the virtual host configuration depending on Phraseanet configuration');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$output->writeln('');
|
||||
|
||||
if ($this->container['phraseanet.xsendfile-factory']->isXSendFileModeEnabled()) {
|
||||
throw new \LogicException('XSendFile mode is already activated');
|
||||
}
|
||||
|
||||
if (!$this->container['phraseanet.static-file-factory']->isStaticFileModeEnabled()) {
|
||||
$output->writeln('Static file support is <error>disabled</error>');
|
||||
$ret = 1;
|
||||
} else {
|
||||
$output->writeln('Static file support is <info>enabled</info>');
|
||||
$ret = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
$configuration = $this->container['phraseanet.static-file-factory']->getMode(true, true)->getVirtualHostConfiguration();
|
||||
$output->writeln('Static file configuration seems <info>OK</info>');
|
||||
$output->writeln($configuration);
|
||||
} catch (RuntimeException $e) {
|
||||
$output->writeln('Static file configuration seems <error>invalid</error>');
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
$output->writeln('');
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
64
lib/Alchemy/Phrasea/Command/Setup/StaticMappingGenerator.php
Normal file
64
lib/Alchemy/Phrasea/Command/Setup/StaticMappingGenerator.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Command\Setup;
|
||||
|
||||
use Alchemy\Phrasea\Command\Command;
|
||||
use Alchemy\Phrasea\Http\StaticFile\StaticFileFactory;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class StaticMappingGenerator extends Command
|
||||
{
|
||||
public function __construct($name = null)
|
||||
{
|
||||
parent::__construct('static-file:generate-mapping');
|
||||
|
||||
$this->addOption('write', 'w', null, 'Writes the configuration')
|
||||
->addOption('enabled', 'e', null, 'Set the enable toggle to `true`')
|
||||
->addArgument('type', InputArgument::REQUIRED, 'The configuration type, either `nginx` or `apache`')
|
||||
->setDescription('Generates Phraseanet Static file configuration');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doExecute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$enabled = $input->getOption('enabled');
|
||||
$type = strtolower($input->getArgument('type'));
|
||||
|
||||
$factory = new StaticFileFactory($this->container['monolog'], true, $type, $this->container['phraseanet.thumb-symlinker']);
|
||||
$mode = $factory->getMode(true);
|
||||
|
||||
$conf = array(
|
||||
'enabled' => $enabled,
|
||||
'type' => $type,
|
||||
'mapping' => $mode->getMapping(),
|
||||
);
|
||||
|
||||
if ($input->getOption('write')) {
|
||||
$output->write("Writing configuration ...");
|
||||
$this->container['phraseanet.configuration']['static-file'] = $conf;
|
||||
$output->writeln(" <info>OK</info>");
|
||||
$output->writeln("");
|
||||
$output->write("It is now strongly recommended to use <info>static-file:dump-configuration</info> command to upgrade your virtual-host");
|
||||
} else {
|
||||
$output->writeln("Configuration will <info>not</info> be written, use <info>--write</info> option to write it");
|
||||
$output->writeln("");
|
||||
$output->writeln(Yaml::dump(array('static-file' => $conf), 4));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user