mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Refactor configuration check
This commit is contained in:
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