mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Refactor configuration check
This commit is contained in:
@@ -18,12 +18,14 @@ use Alchemy\Phrasea\Setup\Version\Probe\Probe38;
|
||||
use Alchemy\Phrasea\Setup\Version\Probe\ProbeInterface as VersionProbeInterface;
|
||||
use Alchemy\Phrasea\Setup\Probe\BinariesProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\CacheServerProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\OpcodeCacheProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\DataboxStructureProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\FilesystemProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\LocalesProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\OpcodeCacheProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\PhpProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\PhraseaProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\SearchEngineProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\SubdefsPathsProbe;
|
||||
use Alchemy\Phrasea\Setup\Probe\SystemProbe;
|
||||
|
||||
class ConfigurationTester
|
||||
@@ -52,12 +54,14 @@ class ConfigurationTester
|
||||
$this->requirements = array(
|
||||
BinariesProbe::create($this->app),
|
||||
CacheServerProbe::create($this->app),
|
||||
DataboxStructureProbe::create($this->app),
|
||||
OpcodeCacheProbe::create($this->app),
|
||||
FilesystemProbe::create($this->app),
|
||||
LocalesProbe::create($this->app),
|
||||
PhpProbe::create($this->app),
|
||||
PhraseaProbe::create($this->app),
|
||||
SearchEngineProbe::create($this->app),
|
||||
SubdefsPathsProbe::create($this->app),
|
||||
SystemProbe::create($this->app),
|
||||
);
|
||||
|
||||
|
48
lib/Alchemy/Phrasea/Setup/Probe/DataboxStructureProbe.php
Normal file
48
lib/Alchemy/Phrasea/Setup/Probe/DataboxStructureProbe.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Setup\Probe;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Setup\RequirementCollection;
|
||||
|
||||
class DataboxStructureProbe extends RequirementCollection implements ProbeInterface
|
||||
{
|
||||
public function __construct(\appbox $appbox)
|
||||
{
|
||||
$this->setName('Databoxes structure');
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
foreach ($databox->get_meta_structure() as $field) {
|
||||
$this->verifyDataboxField($databox->get_dbname(), $field->get_name(), $field->get_original_source(), $field->get_tag()->getTagname());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function verifyDataboxField($dbName, $field, $original, $tagname)
|
||||
{
|
||||
$this->addRequirement(
|
||||
$original === $tagname,
|
||||
"$dbName::$field must be be set to a valid metadata source",
|
||||
"Source \"<strong>$original</strong>\" is not a valid one, please fix it."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return DataboxStructureProbe
|
||||
*/
|
||||
public static function create(Application $app)
|
||||
{
|
||||
return new static($app['phraseanet.appbox']);
|
||||
}
|
||||
}
|
63
lib/Alchemy/Phrasea/Setup/Probe/SubdefsPathsProbe.php
Normal file
63
lib/Alchemy/Phrasea/Setup/Probe/SubdefsPathsProbe.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Alchemy\Phrasea\Setup\Probe;
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
use Alchemy\Phrasea\Setup\RequirementCollection;
|
||||
|
||||
class SubdefsPathsProbe extends RequirementCollection implements ProbeInterface
|
||||
{
|
||||
public function __construct(\appbox $appbox)
|
||||
{
|
||||
$this->setName('Subdefs Paths');
|
||||
|
||||
foreach ($appbox->get_databoxes() as $databox) {
|
||||
$this->ensureWriteableSubdefsPath($databox->get_dbname(), 'document', (string) $databox->get_sxml_structure()->path);
|
||||
foreach ($databox->get_subdef_structure() as $group => $subdefs) {
|
||||
foreach ($subdefs as $subdef) {
|
||||
$this->ensureWriteableSubdefsPath($databox->get_dbname(), $group . '/' . $subdef->get_name(), (string) $databox->get_sxml_structure()->path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function ensureWriteableSubdefsPath($dbName, $sdName, $path)
|
||||
{
|
||||
$this->addRequirement(
|
||||
is_dir($path),
|
||||
"$path ($dbName - $sdName) must be a directory",
|
||||
"Create directory \"<strong>$path</strong>\" directory so that the subdef could be stored."
|
||||
);
|
||||
|
||||
$this->addRequirement(
|
||||
is_readable($path),
|
||||
"$path ($dbName - $sdName) directory must be readable",
|
||||
"Change the permissions of the \"<strong>$path</strong>\" directory so that the web server can read it."
|
||||
);
|
||||
|
||||
$this->addRequirement(
|
||||
is_writable($path),
|
||||
"$path ($dbName - $sdName) directory must be writable",
|
||||
"Change the permissions of the \"<strong>$path</strong>\" directory so that the web server can write into it."
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return SubdefsPathsProbe
|
||||
*/
|
||||
public static function create(Application $app)
|
||||
{
|
||||
return new static($app['phraseanet.appbox']);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user