diff --git a/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php b/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php index e5694ce31f..ba8395ffc3 100644 --- a/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php +++ b/lib/Alchemy/Phrasea/Border/MimeGuesserConfiguration.php @@ -11,7 +11,6 @@ namespace Alchemy\Phrasea\Border; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use MediaVorus\Utils\AudioMimeTypeGuesser; use MediaVorus\Utils\PostScriptMimeTypeGuesser; @@ -24,12 +23,10 @@ class MimeGuesserConfiguration { /** @var PropertyAccess */ private $conf; - private $store; - public function __construct(PropertyAccess $conf, ConfigurationInterface $store) + public function __construct(PropertyAccess $conf) { $this->conf = $conf; - $this->store = $store; } /** @@ -45,8 +42,6 @@ class MimeGuesserConfiguration $guesser->register(new AudioMimeTypeGuesser()); $guesser->register(new VideoMimeTypeGuesser()); - if ($this->store->isSetup()) { - $guesser->register(new CustomExtensionGuesser($this->conf->get(['border-manager', 'extension-mapping'], []))); - } + $guesser->register(new CustomExtensionGuesser($this->conf->get(['border-manager', 'extension-mapping'], []))); } } diff --git a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php index 9b2e74bfcb..fe39bd6a51 100644 --- a/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php +++ b/lib/Alchemy/Phrasea/Command/Developer/RegenerateSqliteDb.php @@ -65,8 +65,11 @@ class RegenerateSqliteDb extends Command } try { - $dbParams = $this->container['configuration.store']->getTestConnectionParameters(); - $dbParams['path'] = $source; + $dbParams = [ + 'driver' => 'pdo_sqlite', + 'path' => $source, + 'charset' => 'UTF8', + ]; $this->container->register(new ORMServiceProvider()); $this->container['EM.dbal-conf'] = $dbParams; diff --git a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php index 854c6b5b9a..89f07e8663 100644 --- a/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php +++ b/lib/Alchemy/Phrasea/Controller/Admin/TaskManager.php @@ -183,7 +183,7 @@ class TaskManager implements ControllerProviderInterface $task = $app['manipulator.task']->create( $job->getName(), $job->getJobId(), - $job->getEditor()->getDefaultSettings($app['configuration.store']), + $job->getEditor()->getDefaultSettings($app['conf']), $job->getEditor()->getDefaultPeriod() ); diff --git a/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php b/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php index 09fae32715..48c59b0551 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/Configuration.php @@ -185,7 +185,10 @@ class Configuration implements ConfigurationInterface $this->delete(); $this->dumpFile($this->config, $this->loadFile(__DIR__ . static::CONFIG_REF), 0600); - return $this->getConfig(); + // force rewrite + $this->getConfig(); + + return $this; } /** @@ -201,15 +204,6 @@ class Configuration implements ConfigurationInterface return $this->autoReload; } - public function getTestConnectionParameters() - { - return [ - 'driver' => 'pdo_sqlite', - 'path' => '/tmp/db.sqlite', - 'charset' => 'UTF8', - ]; - } - private function loadDefaultConfiguration() { return $this->parser->parse($this->loadFile(__DIR__ . static::CONFIG_REF)); diff --git a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ConfigurationLoaderSubscriber.php b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ConfigurationLoaderSubscriber.php index 85dcec024f..4dd5ca619f 100644 --- a/lib/Alchemy/Phrasea/Core/Event/Subscriber/ConfigurationLoaderSubscriber.php +++ b/lib/Alchemy/Phrasea/Core/Event/Subscriber/ConfigurationLoaderSubscriber.php @@ -11,7 +11,6 @@ namespace Alchemy\Phrasea\Core\Event\Subscriber; -use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Core\Configuration\HostConfiguration; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FinishRequestEvent; diff --git a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php index 20e5fa11d0..052a110c07 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/BorderManagerServiceProvider.php @@ -100,12 +100,14 @@ class BorderManagerServiceProvider implements ServiceProviderInterface }); $app['border-manager.mime-guesser-configuration'] = $app->share(function (Application $app) { - return new MimeGuesserConfiguration($app['conf'], $app['configuration.store']); + return new MimeGuesserConfiguration($app['conf']); }); } public function boot(Application $app) { - $app['border-manager.mime-guesser-configuration']->register(); + if ($app['configuration.store']->isSetup()) { + $app['border-manager.mime-guesser-configuration']->register(); + } } } diff --git a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php index 594d553f67..fd14793d2e 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/TasksServiceProvider.php @@ -49,7 +49,7 @@ class TasksServiceProvider implements ServiceProviderInterface }); $app['task-manager.status'] = $app->share(function (Application $app) { - return new TaskManagerStatus($app['configuration.store']); + return new TaskManagerStatus($app['conf']); }); $app['task-manager.live-information'] = $app->share(function (Application $app) { diff --git a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php index d52e72acfb..f6c8918f7c 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/AbstractConfigurationPanel.php @@ -40,9 +40,7 @@ abstract class AbstractConfigurationPanel implements ConfigurationPanelInterface */ public function saveConfiguration(array $configuration) { - $conf = $this->conf->getConfig(); - $conf['main']['search-engine']['options'] = $configuration; - $this->conf->setConfig($conf); + $this->conf->set(['main', 'search-engine', 'options'], $configuration); return $this; } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php index 3e7605671d..fff787e866 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ConfigurationPanel.php @@ -12,15 +12,15 @@ namespace Alchemy\Phrasea\SearchEngine\Elastic; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Alchemy\Phrasea\SearchEngine\AbstractConfigurationPanel; use Symfony\Component\HttpFoundation\Request; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; class ConfigurationPanel extends AbstractConfigurationPanel { private $searchEngine; - public function __construct(ElasticSearchEngine $engine, ConfigurationInterface $conf) + public function __construct(ElasticSearchEngine $engine, PropertyAccess $conf) { $this->searchEngine = $engine; $this->conf = $conf; @@ -62,6 +62,6 @@ class ConfigurationPanel extends AbstractConfigurationPanel */ public function getConfiguration() { - return isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : []; + return $this->conf->get(['main', 'search-engine', 'options'], []); } } diff --git a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php index d6a93d8a87..99f3fee79e 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Elastic/ElasticSearchEngine.php @@ -94,7 +94,7 @@ class ElasticSearchEngine implements SearchEngineInterface public function getConfigurationPanel() { if (!$this->configurationPanel) { - $this->configurationPanel = new ConfigurationPanel($this, $this->app['configuration.store']); + $this->configurationPanel = new ConfigurationPanel($this, $this->app['conf']); } return $this->configurationPanel; diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php index aebd941e67..d9e97f60d4 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/ConfigurationPanel.php @@ -12,16 +12,16 @@ namespace Alchemy\Phrasea\SearchEngine\Phrasea; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Alchemy\Phrasea\SearchEngine\AbstractConfigurationPanel; use Symfony\Component\HttpFoundation\Request; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; class ConfigurationPanel extends AbstractConfigurationPanel { protected $charsets; protected $searchEngine; - public function __construct(PhraseaEngine $engine, ConfigurationInterface $conf) + public function __construct(PhraseaEngine $engine, PropertyAccess $conf) { $this->searchEngine = $engine; $this->conf = $conf; @@ -75,7 +75,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel */ public function getConfiguration() { - $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : []; + $configuration = $this->conf->get(['main', 'search-engine', 'options'], []); if (!is_array($configuration)) { $configuration = []; diff --git a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php index 77527adabc..831b8148f1 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/Phrasea/PhraseaEngine.php @@ -223,7 +223,7 @@ class PhraseaEngine implements SearchEngineInterface public function getConfigurationPanel() { if (!$this->configurationPanel) { - $this->configurationPanel = new ConfigurationPanel($this, $this->app['configuration.store']); + $this->configurationPanel = new ConfigurationPanel($this, $this->app['conf']); } return $this->configurationPanel; diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php index 6fd5ebc597..2264e6875f 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/ConfigurationPanel.php @@ -11,11 +11,11 @@ namespace Alchemy\Phrasea\SearchEngine\SphinxSearch; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Alchemy\Phrasea\SearchEngine\AbstractConfigurationPanel; use Alchemy\Phrasea\Application; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Finder\Finder; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; class ConfigurationPanel extends AbstractConfigurationPanel { @@ -24,7 +24,7 @@ class ConfigurationPanel extends AbstractConfigurationPanel protected $charsets; protected $searchEngine; - public function __construct(SphinxSearchEngine $engine, ConfigurationInterface $conf) + public function __construct(SphinxSearchEngine $engine, PropertyAccess $conf) { $this->searchEngine = $engine; $this->conf = $conf; @@ -86,23 +86,11 @@ class ConfigurationPanel extends AbstractConfigurationPanel */ public function getConfiguration() { - $configuration = isset($this->conf['main']['search-engine']['options']) ? $this->conf['main']['search-engine']['options'] : []; + $configuration = $this->conf->get(['main', 'search-engine', 'options'], []); return self::populateConfiguration($configuration); } - /** - * {@inheritdoc} - */ - public function saveConfiguration(array $configuration) - { - $conf = $this->conf->getConfig(); - $conf['main']['search-engine']['options'] = $configuration; - $this->conf->setConfig($conf); - - return $this; - } - /** * Returns all the charset Sphinx Search supports * diff --git a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php index 87224fdca9..0515c1b43a 100644 --- a/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php +++ b/lib/Alchemy/Phrasea/SearchEngine/SphinxSearch/SphinxSearchEngine.php @@ -173,7 +173,7 @@ class SphinxSearchEngine implements SearchEngineInterface public function getConfigurationPanel() { if (!$this->configurationPanel) { - $this->configurationPanel = new ConfigurationPanel($this, $this->app['configuration.store']); + $this->configurationPanel = new ConfigurationPanel($this, $this->app['conf']); } return $this->configurationPanel; diff --git a/lib/Alchemy/Phrasea/Setup/Installer.php b/lib/Alchemy/Phrasea/Setup/Installer.php index 86a4e42fbf..d9c4acc37e 100644 --- a/lib/Alchemy/Phrasea/Setup/Installer.php +++ b/lib/Alchemy/Phrasea/Setup/Installer.php @@ -95,7 +95,7 @@ class Installer $this->app['manipulator.task']->create( $job->getName(), $job->getJobId(), - $job->getEditor()->getDefaultSettings($this->app['configuration.store']), + $job->getEditor()->getDefaultSettings($this->app['conf']), $job->getEditor()->getDefaultPeriod() ); } @@ -171,7 +171,7 @@ class Installer private function createConfigFile($abConn, $serverName, $binaryData) { - $config = $this->app['configuration.store']->initialize(); + $config = $this->app['configuration.store']->initialize()->getConfig(); foreach ($abConn->get_credentials() as $key => $value) { $key = $key == 'hostname' ? 'host' : $key; diff --git a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php index aa721b6a75..dc62369e2f 100644 --- a/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php +++ b/lib/Alchemy/Phrasea/Setup/Version/Migration/Migration35.php @@ -12,6 +12,7 @@ namespace Alchemy\Phrasea\Setup\Version\Migration; use Alchemy\Phrasea\Application; +use Alchemy\Phrasea\Core\Configuration\Configuration; class Migration35 implements MigrationInterface { @@ -29,7 +30,7 @@ class Migration35 implements MigrationInterface throw new \LogicException('Required config files not found'); } - $config = $this->app['configuration.store']->initialize(); + $config = $this->app['configuration.store']->initialize()->getConfig(); foreach ($config['registration-fields'] as $key => $field) { $config['registration-fields'][$key]['required'] = (boolean) $field['required']; diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php index 6a791fd052..59c822e43f 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/ArchiveEditor.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; class ArchiveEditor extends AbstractEditor { @@ -34,7 +34,7 @@ class ArchiveEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { return << diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php index f4c2aa3fc4..220537de5e 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/DefaultEditor.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; class DefaultEditor extends AbstractEditor { @@ -34,7 +34,7 @@ class DefaultEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { return << diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/EditorInterface.php b/lib/Alchemy/Phrasea/TaskManager/Editor/EditorInterface.php index b52e68c9b8..12c8923ece 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/EditorInterface.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/EditorInterface.php @@ -12,7 +12,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; @@ -53,11 +53,11 @@ interface EditorInterface * Configuration is used to populate the default configuration with * configuration values. * - * @param Configuration $config + * @param PropertyAccess $config * * @return string An XML string */ - public function getDefaultSettings(ConfigurationInterface $config = null); + public function getDefaultSettings(PropertyAccess $config = null); /** * Returns the default period of the job. diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php index 13e3ff4da5..fd1cf4c7af 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpEditor.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; class FtpEditor extends AbstractEditor { @@ -34,7 +34,7 @@ class FtpEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { return << diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php index cd3289cebb..9e3466be9c 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/FtpPullEditor.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; class FtpPullEditor extends AbstractEditor { @@ -34,7 +34,7 @@ class FtpPullEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { return << diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php index f0ba1677f4..8abc495cff 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/PhraseanetIndexerEditor.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; class PhraseanetIndexerEditor extends AbstractEditor { @@ -35,18 +35,16 @@ class PhraseanetIndexerEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { if (null !== $config) { - $database = $config['main']['database']; - return ' - '.$database['host'].' - '.$database['port'].' - '.$database['dbname'].' - '.$database['user'].' - '.$database['password'].' + '.$config->get(['main', 'database', 'host']).' + '.$config->get(['main', 'database', 'port']).' + '.$config->get(['main', 'database', 'dbname']).' + '.$config->get(['main', 'database', 'user']).' + '.$config->get(['main', 'database', 'password']).' 25200 0 diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php index 17521ebc19..e1aed49a2e 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/RecordMoverEditor.php @@ -12,7 +12,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; use Alchemy\Phrasea\Application; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Alchemy\Phrasea\TaskManager\Job\RecordMoverJob; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -74,7 +74,7 @@ class RecordMoverEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { return << diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php index 394de7afca..f8c89f4795 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/SubdefsEditor.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; class SubdefsEditor extends AbstractEditor { @@ -34,7 +34,7 @@ class SubdefsEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { return << diff --git a/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php b/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php index b44593adf7..08ee5711c6 100644 --- a/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php +++ b/lib/Alchemy/Phrasea/TaskManager/Editor/WriteMetadataEditor.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager\Editor; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; class WriteMetadataEditor extends AbstractEditor { @@ -34,7 +34,7 @@ class WriteMetadataEditor extends AbstractEditor /** * {@inheritdoc} */ - public function getDefaultSettings(ConfigurationInterface $config = null) + public function getDefaultSettings(PropertyAccess $config = null) { return << diff --git a/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php b/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php index 92f56b715d..8baa95eb73 100644 --- a/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php +++ b/lib/Alchemy/Phrasea/TaskManager/TaskManagerStatus.php @@ -11,7 +11,7 @@ namespace Alchemy\Phrasea\TaskManager; -use Alchemy\Phrasea\Core\Configuration\ConfigurationInterface; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; /** * Gets and Sets the Task Manager status @@ -24,7 +24,7 @@ class TaskManagerStatus const STATUS_STARTED = 'started'; const STATUS_STOPPED = 'stopped'; - public function __construct(ConfigurationInterface $conf) + public function __construct(PropertyAccess $conf) { $this->conf = $conf; } @@ -64,34 +64,26 @@ class TaskManagerStatus { $this->ensureConfigurationSchema(); - return $this->conf['main']['task-manager']['status']; + return $this->conf->get(['main', 'task-manager', 'status']); } private function setStatus($status) { $this->ensureConfigurationSchema(); - $mainConf = $this->conf['main']; - $mainConf['task-manager']['status'] = $status; - $this->conf['main'] = $mainConf; + $this->conf->set(['main', 'task-manager', 'status'], $status); } private function ensureConfigurationSchema() { - if (!isset($this->conf['main']['task-manager'])) { - $mainConf = $this->conf['main']; - $mainConf['task-manager'] = ['status' => static::STATUS_STARTED]; - $this->conf['main'] = $mainConf; + if (!$this->conf->has(['main', 'task-manager'])) { + $this->conf->set(['main', 'task-manager'], ['status' => static::STATUS_STARTED]); return; } - if (!isset($this->conf['main']['task-manager']['status'])) { - $mainConf = $this->conf['main']; - $mainConf['task-manager']['status'] = static::STATUS_STARTED; - $this->conf['main'] = $mainConf; - } elseif (!$this->isValidStatus($this->conf['main']['task-manager']['status'])) { - $mainConf = $this->conf['main']; - $mainConf['task-manager']['status'] = static::STATUS_STARTED; - $this->conf['main'] = $mainConf; + if (!$this->conf->has(['main', 'task-manager', 'status'])) { + $this->conf->set(['main', 'task-manager', 'status'], static::STATUS_STARTED); + } elseif (!$this->isValidStatus($this->conf->get(['main', 'task-manager', 'status']))) { + $this->conf->set(['main', 'task-manager'], ['status' => static::STATUS_STARTED]); } } diff --git a/lib/classes/API/V1/result.php b/lib/classes/API/V1/result.php index 65c1d0650b..659e5e53c9 100644 --- a/lib/classes/API/V1/result.php +++ b/lib/classes/API/V1/result.php @@ -199,9 +199,7 @@ class API_V1_result $this->app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent()); - $conf = $this->app['configuration.store']; - - if (isset($conf['main']['api-timers']) && true === $conf['main']['api-timers']) { + if ($this->app['conf']->get(['main', 'api-timers'], false)) { $ret['timers'] = $this->app['api.timers']->toArray(); } diff --git a/lib/classes/patch/380alpha3b.php b/lib/classes/patch/380alpha3b.php index aba048d26c..52d02d1af0 100644 --- a/lib/classes/patch/380alpha3b.php +++ b/lib/classes/patch/380alpha3b.php @@ -56,7 +56,10 @@ class patch_380alpha3b implements patchInterface */ public function apply(base $appbox, Application $app) { - $app['configuration.store']->setDefault('main', 'search-engine'); + $app['conf']->set(['main', 'search-engine'], [ + 'type' => 'Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine', + 'options' => [], + ]); return true; } diff --git a/lib/classes/patch/390alpha6a.php b/lib/classes/patch/390alpha6a.php index 18868b0fdd..86b2e0f57c 100644 --- a/lib/classes/patch/390alpha6a.php +++ b/lib/classes/patch/390alpha6a.php @@ -13,7 +13,6 @@ use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Model\Entities\FtpExport; use Alchemy\Phrasea\Model\Entities\FtpExportElement; use Gedmo\Timestampable\TimestampableListener; -use Doctrine\ORM\NoResultException; class patch_390alpha6a extends patchAbstract { diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php b/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php index 3bd2482349..730a8f6cbf 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php @@ -23,16 +23,4 @@ class ConfigurationTest extends ConfigurationTestCase return new Configuration($yaml, $compiler, $confFile, $compiledFile, $autoreload); } - - public function testGetTestConnectionConf() - { - $configFile = __DIR__ . '/Fixtures/configuration.yml'; - - $conf = $this->provideConfiguration($configFile, null, null, null, true); - $data = $conf->getTestConnectionParameters(); - - $this->assertArrayHasKey('driver', $data); - $this->assertArrayHasKey('path', $data); - $this->assertArrayHasKey('charset', $data); - } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTestCase.php b/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTestCase.php index 89e0648f02..df0f67efca 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTestCase.php @@ -55,7 +55,8 @@ abstract class ConfigurationTestCase extends \PhraseanetTestCase $compiled = $this->compiled; $conf = $this->provideConfiguration($configFile); - $config = $conf->initialize(); + $this->assertSame($conf, $conf->initialize()); + $config = $conf->getConfig(); $this->assertArrayHasKey('main', $config); $this->assertFileExists($compiled); diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaConfigurationPanelTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaConfigurationPanelTest.php index f54dda5124..76e0566f55 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaConfigurationPanelTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/PhraseaConfigurationPanelTest.php @@ -9,6 +9,6 @@ class PhraseaConfigurationPanelTest extends ConfigurationPanelAbstractTest { public function getPanel() { - return new ConfigurationPanel(new PhraseaEngine(self::$DI['app']), self::$DI['app']['configuration.store']); + return new ConfigurationPanel(new PhraseaEngine(self::$DI['app']), self::$DI['app']['conf']); } } diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchConfigurationPanelTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchConfigurationPanelTest.php index 569f2ed3cc..e042973fc8 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchConfigurationPanelTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/SphinxSearchConfigurationPanelTest.php @@ -9,7 +9,7 @@ class SphinxSearchConfigurationPanelTest extends ConfigurationPanelAbstractTest { public function getPanel() { - return new ConfigurationPanel(new SphinxSearchEngine(self::$DI['app'], 'localhost', 9306, 'localhost', 9308), self::$DI['app']['configuration.store']); + return new ConfigurationPanel(new SphinxSearchEngine(self::$DI['app'], 'localhost', 9306, 'localhost', 9308), self::$DI['app']['conf']); } public function testGetAVailableCharsets() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php index 095b361110..ca8ac9fc73 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/Editor/EditorTestCase.php @@ -43,7 +43,7 @@ abstract class EditorTestCase extends \PhraseanetTestCase $editor = $this->getEditor(); $dom = new \DOMDocument(); $dom->strictErrorChecking = true; - $this->assertTrue(false !== $dom->loadXML($editor->getDefaultSettings(self::$DI['app']['configuration.store']))); + $this->assertTrue(false !== $dom->loadXML($editor->getDefaultSettings(self::$DI['app']['conf']))); } public function testGetDefaultSettingsWithoutConfiguration() diff --git a/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php b/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php index ecd7c53e1a..d3e03a6609 100644 --- a/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php +++ b/tests/Alchemy/Tests/Phrasea/TaskManager/TaskManagerStatusTest.php @@ -2,6 +2,7 @@ namespace Alchemy\Tests\Phrasea\TaskManager; +use Alchemy\Phrasea\Core\Configuration\PropertyAccess; use Alchemy\Phrasea\TaskManager\TaskManagerStatus; use Alchemy\Tests\Phrasea\MockArrayConf; @@ -16,7 +17,7 @@ class TaskManagerStatusTest extends \PhraseanetTestCase $expected = $conf->getConfig(); $expected['main']['task-manager']['status'] = TaskManagerStatus::STATUS_STARTED; - $status = new TaskManagerStatus($conf); + $status = new TaskManagerStatus(new PropertyAccess($conf)); $status->start(); $this->assertEquals($expected, $conf->getConfig()); @@ -45,7 +46,7 @@ class TaskManagerStatusTest extends \PhraseanetTestCase $expected = $conf->getConfig(); $expected['main']['task-manager']['status'] = TaskManagerStatus::STATUS_STOPPED; - $status = new TaskManagerStatus($conf); + $status = new TaskManagerStatus(new PropertyAccess($conf)); $status->stop(); $this->assertEquals($expected, $conf->getConfig()); @@ -56,7 +57,7 @@ class TaskManagerStatusTest extends \PhraseanetTestCase */ public function testIsRunning($data, $expectedStatus, $isRunning) { - $conf = new MockArrayConf($data); + $conf = new PropertyAccess(new MockArrayConf($data)); $status = new TaskManagerStatus($conf); $this->assertEquals($isRunning, $status->isRunning()); } @@ -77,7 +78,7 @@ class TaskManagerStatusTest extends \PhraseanetTestCase */ public function testGetStatus($data, $expectedStatus, $isRunning) { - $conf = new MockArrayConf($data); + $conf = new PropertyAccess(new MockArrayConf($data)); $status = new TaskManagerStatus($conf); $this->assertEquals($expectedStatus, $status->getStatus()); } diff --git a/tests/classes/patch/380alpha3bTest.php b/tests/classes/patch/380alpha3bTest.php index d4c814a931..576fe17beb 100644 --- a/tests/classes/patch/380alpha3bTest.php +++ b/tests/classes/patch/380alpha3bTest.php @@ -15,10 +15,15 @@ class patch_380alpha3bTest extends \PhraseanetTestCase $app = self::$DI['app']; - $app['configuration.store'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); - $app['configuration.store']->expects($this->once()) - ->method('setDefault') - ->with('main', 'search-engine'); + $app['conf'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\PropertyAccess') + ->disableOriginalConstructor() + ->getMock(); + $app['conf']->expects($this->once()) + ->method('set') + ->with(['main', 'search-engine'], [ + 'type' => 'Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine', + 'options' => [], + ]); $this->assertTrue($patch->apply($appbox, $app)); }