Use configuration property accessor

This commit is contained in:
Romain Neutron
2013-11-18 18:45:25 +01:00
parent 94be7c5498
commit 7e0a3c7338
87 changed files with 209 additions and 265 deletions

View File

@@ -63,7 +63,7 @@ $cli = new CLI("
under certain conditions; type `about:license' for details.\n\n" under certain conditions; type `about:license' for details.\n\n"
. ' Phraseanet Developer Tools ', Version::getName() . ' ' . Version::getNumber()); . ' Phraseanet Developer Tools ', Version::getName() . ' ' . Version::getNumber());
if ($cli['configuration']->isSetup()) { if ($cli['configuration.store']->isSetup()) {
$helpers = [ $helpers = [
'db' => new ConnectionHelper($cli['EM']->getConnection()), 'db' => new ConnectionHelper($cli['EM']->getConnection()),
'em' => new EntityManagerHelper($cli['EM']) 'em' => new EntityManagerHelper($cli['EM'])

View File

@@ -240,8 +240,8 @@ class Application extends SilexApplication
'swftools.timeout' => 'swftools_timeout', 'swftools.timeout' => 'swftools_timeout',
'unoconv.timeout' => 'unoconv_timeout', 'unoconv.timeout' => 'unoconv_timeout',
] as $parameter => $key) { ] as $parameter => $key) {
if (isset($this['configuration']['binaries'][$key])) { if ($this['conf']->has(['binaries', $key])) {
$configuration[$parameter] = $this['configuration']['binaries'][$key]; $configuration[$parameter] = $this['conf']->get(['binaries', $key]);
} }
} }
@@ -550,8 +550,8 @@ class Application extends SilexApplication
private function setupUrlGenerator() private function setupUrlGenerator()
{ {
$this['url_generator'] = $this->share($this->extend('url_generator', function ($urlGenerator, $app) { $this['url_generator'] = $this->share($this->extend('url_generator', function ($urlGenerator, $app) {
if ($app['configuration']->isSetup()) { if ($app['configuration.store']->isSetup()) {
$data = parse_url($app['configuration']['main']['servername']); $data = parse_url($app['conf']->get(['main', 'servername']));
if (isset($data['scheme'])) { if (isset($data['scheme'])) {
$urlGenerator->getContext()->setScheme($data['scheme']); $urlGenerator->getContext()->setScheme($data['scheme']);

View File

@@ -25,7 +25,7 @@ class Configuration extends Command
protected function doExecute(InputInterface $input, OutputInterface $output) protected function doExecute(InputInterface $input, OutputInterface $output)
{ {
$this->container['configuration']->compileAndWrite(); $this->container['configuration.store']->compileAndWrite();
$output->writeln("Confguration compiled."); $output->writeln("Confguration compiled.");
return 0; return 0;

View File

@@ -32,7 +32,7 @@ class RegenerateSqliteDb extends Command
} }
try { try {
$dbParams = $this->container['configuration']->getTestConnectionParameters(); $dbParams = $this->container['configuration.store']->getTestConnectionParameters();
$dbParams['path'] = $source; $dbParams['path'] = $source;
$this->container->register(new ORMServiceProvider()); $this->container->register(new ORMServiceProvider());

View File

@@ -53,7 +53,7 @@ class XSendFileMappingGenerator extends Command
if ($input->getOption('write')) { if ($input->getOption('write')) {
$output->write("Writing configuration ..."); $output->write("Writing configuration ...");
$this->container['configuration']['xsendfile'] = $conf; $this->container['conf']->set('xsendfile', $conf);
$output->writeln(" <info>OK</info>"); $output->writeln(" <info>OK</info>");
$output->writeln(""); $output->writeln("");
$output->write("It is now strongly recommended to use <info>xsendfile:dump-configuration</info> command to upgrade your virtual-host"); $output->write("It is now strongly recommended to use <info>xsendfile:dump-configuration</info> command to upgrade your virtual-host");

View File

@@ -46,7 +46,7 @@ abstract class AbstractDelivery implements ControllerProviderInterface
$referrer = $_SERVER['HTTP_REFERER']; $referrer = $_SERVER['HTTP_REFERER'];
} }
$record->log_view($log_id, $referrer, $app['configuration']['main']['key']); $record->log_view($log_id, $referrer, $app['conf']->get(['main', 'key']));
} catch (\Exception $e) { } catch (\Exception $e) {
} }

View File

@@ -157,9 +157,7 @@ class Databoxes implements ControllerProviderInterface
} }
if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) { if ((null === $request->request->get('new_settings')) && (null !== $dataTemplate = $request->request->get('new_data_template'))) {
$connexion = $app['conf']->get(['main', 'database']);
$configuration = $app['configuration'];
$connexion = $configuration['main']['database'];
$hostname = $connexion['host']; $hostname = $connexion['host'];
$port = $connexion['port']; $port = $connexion['port'];
@@ -229,8 +227,7 @@ class Databoxes implements ControllerProviderInterface
if ((null === $request->request->get('new_settings'))) { if ((null === $request->request->get('new_settings'))) {
try { try {
$configuration = $app['configuration']; $connexion = $app['conf']->get(['main', 'database']);
$connexion = $configuration['main']['database'];
$hostname = $connexion['host']; $hostname = $connexion['host'];
$port = $connexion['port']; $port = $connexion['port'];

View File

@@ -139,7 +139,7 @@ class TaskManager implements ControllerProviderInterface
$task = $app['manipulator.task']->create( $task = $app['manipulator.task']->create(
$job->getName(), $job->getName(),
$job->getJobId(), $job->getJobId(),
$job->getEditor()->getDefaultSettings($app['configuration']), $job->getEditor()->getDefaultSettings($app['configuration.store']),
$job->getEditor()->getDefaultPeriod() $job->getEditor()->getDefaultPeriod()
); );

View File

@@ -110,7 +110,7 @@ class Session implements ControllerProviderInterface
} }
if (in_array($app['session']->get('phraseanet.message'), ['1', null])) { if (in_array($app['session']->get('phraseanet.message'), ['1', null])) {
if ($app['configuration']['main']['maintenance']) { if ($app['conf']->get(['main', 'maintenance'])) {
$ret['message'] .= _('The application is going down for maintenance, please logout.'); $ret['message'] .= _('The application is going down for maintenance, please logout.');
} }

View File

@@ -36,12 +36,12 @@ class CLIDriversServiceProvider implements ServiceProviderInterface
$extraDirs[] = $app['root.path'] . '/node_modules/.bin'; $extraDirs[] = $app['root.path'] . '/node_modules/.bin';
} }
if (!$app['configuration']->isSetup()) { if (!$app['configuration.store']->isSetup()) {
return $app['executable-finder']->find($name, null, $extraDirs); return $app['executable-finder']->find($name, null, $extraDirs);
} }
if (isset($app['configuration']['binaries'][$configName])) { if ($app['conf']->has(['binaries', $configName])) {
return $app['configuration']['binaries'][$configName]; return $app['conf']->get(['binaries', $configName]);
} }
return $app['executable-finder']->find($name, null, $extraDirs); return $app['executable-finder']->find($name, null, $extraDirs);

View File

@@ -56,8 +56,7 @@ class PluginServiceProvider implements ServiceProviderInterface
}); });
$app['plugins.composer-installer'] = $app->share(function (Application $app) { $app['plugins.composer-installer'] = $app->share(function (Application $app) {
$binaries = $app['configuration']['binaries']; $phpBinary = $app['conf']->get(['binaries', 'php_binary'], null);
$phpBinary = isset($binaries['php_binary']) ? $binaries['php_binary'] : null;
if (!is_executable($phpBinary)) { if (!is_executable($phpBinary)) {
$finder = new PhpExecutableFinder(); $finder = new PhpExecutableFinder();

View File

@@ -41,11 +41,8 @@ class DebuggerSubscriber implements EventSubscriberInterface
return; return;
} }
if ($this->app['configuration']->isSetup() if ($this->app['configuration.store']->isSetup() && $this->app['conf']->has(['debugger', 'allowed-ips'])) {
&& isset($this->app['configuration']['debugger']) $allowedIps = $this->app['conf']->get(['debugger', 'allowed-ips']);
&& isset($this->app['configuration']['debugger']['allowed-ips'])) {
$allowedIps = $this->app['configuration']['debugger']['allowed-ips'];
$allowedIps = is_array($allowedIps) ? $allowedIps : [$allowedIps]; $allowedIps = is_array($allowedIps) ? $allowedIps : [$allowedIps];
} else { } else {
$allowedIps = []; $allowedIps = [];

View File

@@ -34,7 +34,7 @@ class MaintenanceSubscriber implements EventSubscriberInterface
public function checkForMaintenance(GetResponseEvent $event) public function checkForMaintenance(GetResponseEvent $event)
{ {
if ($this->app['configuration']->isSetup() && $this->app['configuration']['main']['maintenance']) { if ($this->app['configuration.store']->isSetup() && $this->app['conf']->get(['main', 'maintenance'])) {
$this->app->abort(503, 'Service Temporarily Unavailable', ['Retry-After' => 3600]); $this->app->abort(503, 'Service Temporarily Unavailable', ['Retry-After' => 3600]);
} }
} }

View File

@@ -36,7 +36,7 @@ class PersistentCookieSubscriber implements EventSubscriberInterface
{ {
$request = $event->getRequest(); $request = $event->getRequest();
if ($this->app['configuration']->isSetup() && $request->cookies->has('persistent') && !$this->app['authentication']->isAuthenticated()) { if ($this->app['configuration.store']->isSetup() && $request->cookies->has('persistent') && !$this->app['authentication']->isAuthenticated()) {
if (false !== $session = $this->app['authentication.persistent-manager']->getSession($request->cookies->get('persistent'))) { if (false !== $session = $this->app['authentication.persistent-manager']->getSession($request->cookies->get('persistent'))) {
$this->app['authentication']->refreshAccount($session); $this->app['authentication']->refreshAccount($session);
} }

View File

@@ -35,7 +35,7 @@ class XSendFileSubscriber implements EventSubscriberInterface
public function applyHeaders(GetResponseEvent $event) public function applyHeaders(GetResponseEvent $event)
{ {
if (!$this->app['configuration']->isSetup()) { if (!$this->app['configuration.store']->isSetup()) {
return; return;
} }

View File

@@ -53,7 +53,7 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
}); });
$app['authentication.providers.account-creator'] = $app->share(function (Application $app) { $app['authentication.providers.account-creator'] = $app->share(function (Application $app) {
$authConf = $app['configuration']['authentication']; $authConf = $app['conf']->get('authentication');
$templates = array_filter(array_map(function ($templateId) use ($app) { $templates = array_filter(array_map(function ($templateId) use ($app) {
try { try {
if (is_int($templateId) || ctype_digit($templateId)) { if (is_int($templateId) || ctype_digit($templateId)) {
@@ -78,7 +78,7 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
$providers = new ProvidersCollection(); $providers = new ProvidersCollection();
$authConf = $app['configuration']['authentication']; $authConf = $app['conf']->get('authentication');
foreach ($authConf['providers'] as $providerId => $data) { foreach ($authConf['providers'] as $providerId => $data) {
if (isset($data['enabled']) && false === $data['enabled']) { if (isset($data['enabled']) && false === $data['enabled']) {
continue; continue;
@@ -94,7 +94,7 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
}); });
$app['auth.password-encoder'] = $app->share(function (Application $app) { $app['auth.password-encoder'] = $app->share(function (Application $app) {
return new PasswordEncoder($app['configuration']['main']['key']); return new PasswordEncoder($app['conf']->get(['main','key']));
}); });
$app['auth.old-password-encoder'] = $app->share(function (Application $app) { $app['auth.old-password-encoder'] = $app->share(function (Application $app) {
@@ -102,7 +102,7 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
}); });
$app['auth.native.failure-manager'] = $app->share(function (Application $app) { $app['auth.native.failure-manager'] = $app->share(function (Application $app) {
$authConf = $app['configuration']['authentication']['captcha']; $authConf = $app['conf']->get(['authentication', 'captcha']);
return new FailureManager($app['EM'], $app['recaptcha'], isset($authConf['trials-before-display']) ? $authConf['trials-before-display'] : 9); return new FailureManager($app['EM'], $app['recaptcha'], isset($authConf['trials-before-display']) ? $authConf['trials-before-display'] : 9);
}); });
@@ -112,7 +112,7 @@ class AuthenticationManagerServiceProvider implements ServiceProviderInterface
}); });
$app['auth.native'] = $app->share(function (Application $app) { $app['auth.native'] = $app->share(function (Application $app) {
$authConf = $app['configuration']['authentication']; $authConf = $app['conf']->get('authentication');
if ($authConf['captcha']['enabled']) { if ($authConf['captcha']['enabled']) {
return new FailureHandledNativeAuthentication( return new FailureHandledNativeAuthentication(

View File

@@ -30,7 +30,7 @@ class BorderManagerServiceProvider implements ServiceProviderInterface
} }
$options = $app['configuration']['border-manager']; $options = $app['conf']->get('border-manager');
$registeredCheckers = []; $registeredCheckers = [];

View File

@@ -41,13 +41,13 @@ class CacheServiceProvider implements ServiceProviderInterface
}); });
$app['cache'] = $app->share(function (Application $app) { $app['cache'] = $app->share(function (Application $app) {
$conf = $app['configuration']['main']['cache']; $conf = $app['conf']->get(['main', 'cache']);
return $app['phraseanet.cache-service']->factory('cache', $conf['type'], $conf['options']); return $app['phraseanet.cache-service']->factory('cache', $conf['type'], $conf['options']);
}); });
$app['opcode-cache'] = $app->share(function (Application $app) { $app['opcode-cache'] = $app->share(function (Application $app) {
$conf = $app['configuration']['main']['opcodecache']; $conf = $app['conf']->get(['main', 'opcodecache']);
return $app['phraseanet.cache-service']->factory('cache', $conf['type'], $conf['options']); return $app['phraseanet.cache-service']->factory('cache', $conf['type'], $conf['options']);
}); });

View File

@@ -59,7 +59,7 @@ class ConfigurationServiceProvider implements ServiceProviderInterface
{ {
$app['dispatcher'] = $app->share( $app['dispatcher'] = $app->share(
$app->extend('dispatcher', function ($dispatcher, SilexApplication $app) { $app->extend('dispatcher', function ($dispatcher, SilexApplication $app) {
$dispatcher->addSubscriber(new TrustedProxySubscriber($app['configuration'])); $dispatcher->addSubscriber(new TrustedProxySubscriber($app['configuration.store']));
return $dispatcher; return $dispatcher;
}) })

View File

@@ -38,10 +38,8 @@ class LocaleServiceProvider implements ServiceProviderInterface
$app['locales.available'] = $app->share(function (Application $app) { $app['locales.available'] = $app->share(function (Application $app) {
$availableLanguages = PhraseaApplication::getAvailableLanguages(); $availableLanguages = PhraseaApplication::getAvailableLanguages();
if ($app['configuration']->isSetup() if ($app['configuration.store']->isSetup() && $app['conf']->has(['main', 'languages'])) {
&& isset($app['configuration']['main']['languages']) $languages = $app['conf']->get(['main', 'languages']);
&& !empty($app['configuration']['main']['languages'])) {
$languages = $app['configuration']['main']['languages'];
$enabledLanguages = $availableLanguages; $enabledLanguages = $availableLanguages;
foreach ($enabledLanguages as $code => $language) { foreach ($enabledLanguages as $code => $language) {

View File

@@ -100,17 +100,17 @@ class ORMServiceProvider implements ServiceProviderInterface
}); });
$app['EM.opcode-cache-type'] = $app->share(function (Application $app) { $app['EM.opcode-cache-type'] = $app->share(function (Application $app) {
return $app['configuration']['main']['opcodecache']['type']; return $app['conf']->get(['main', 'opcodecache', 'type']);
}); });
$app['EM.opcode-cache-options'] = $app->share(function (Application $app) { $app['EM.opcode-cache-options'] = $app->share(function (Application $app) {
return $app['configuration']['main']['opcodecache']['options']; return $app['conf']->get(['main', 'opcodecache', 'options']);
}); });
$app['EM.cache-type'] = $app->share(function (Application $app) { $app['EM.cache-type'] = $app->share(function (Application $app) {
return $app['configuration']['main']['cache']['type']; return $app['conf']->get(['main', 'cache', 'type']);
}); });
$app['EM.cache-options'] = $app->share(function (Application $app) { $app['EM.cache-options'] = $app->share(function (Application $app) {
return $app['configuration']['main']['cache']['options']; return $app['conf']->get(['main', 'cache', 'options']);
}); });
$app['EM.events-manager'] = $app->share(function (Application $app) { $app['EM.events-manager'] = $app->share(function (Application $app) {
$evm = new EventManager(); $evm = new EventManager();
@@ -121,10 +121,10 @@ class ORMServiceProvider implements ServiceProviderInterface
$app['EM.dbal-conf'] = $app->share(function (Application $app) { $app['EM.dbal-conf'] = $app->share(function (Application $app) {
if ('test' === $app->getEnvironment()) { if ('test' === $app->getEnvironment()) {
return $app['configuration']['main']['database-test']; return $app['conf']->get(['main', 'database-test']);
} }
return $app['configuration']['main']['database']; return $app['conf']->get(['main', 'database']);
}); });
$app['EM'] = $app->share(function (Application $app) { $app['EM'] = $app->share(function (Application $app) {

View File

@@ -21,7 +21,7 @@ class RegistrationServiceProvider implements ServiceProviderInterface
public function register(Application $app) public function register(Application $app)
{ {
$app['registration.fields'] = $app->share(function (Application $app) { $app['registration.fields'] = $app->share(function (Application $app) {
return isset($app['configuration']['registration-fields']) ? $app['configuration']['registration-fields'] : []; return $app['conf']->get('registration-fields', []);
}); });
$app['registration.enabled'] = $app->share(function (Application $app) { $app['registration.enabled'] = $app->share(function (Application $app) {

View File

@@ -24,8 +24,8 @@ class SearchEngineServiceProvider implements ServiceProviderInterface
{ {
$app['phraseanet.SE'] = $app->share(function ($app) { $app['phraseanet.SE'] = $app->share(function ($app) {
$engineClass = $app['configuration']['main']['search-engine']['type']; $engineClass = $app['conf']->get(['main', 'search-engine', 'type']);
$engineOptions = $app['configuration']['main']['search-engine']['options']; $engineOptions = $app['conf']->get(['main', 'search-engine', 'options']);
if (!class_exists($engineClass) || $engineClass instanceof SearchEngineInterface) { if (!class_exists($engineClass) || $engineClass instanceof SearchEngineInterface) {
throw new InvalidArgumentException(sprintf('%s is not valid SearchEngineInterface', $engineClass)); throw new InvalidArgumentException(sprintf('%s is not valid SearchEngineInterface', $engineClass));

View File

@@ -36,18 +36,12 @@ class TasksServiceProvider implements ServiceProviderInterface
}); });
$app['task-manager.listener.options'] = $app->share(function (Application $app) { $app['task-manager.listener.options'] = $app->share(function (Application $app) {
if (isset($app['configuration']['task-manager']) && isset($app['configuration']['task-manager']['listener'])) {
$listenerConf = $app['configuration']['task-manager']['listener'];
} else {
$listenerConf = [];
}
return array_replace([ return array_replace([
'protocol' => 'tcp', 'protocol' => 'tcp',
'host' => '127.0.0.1', 'host' => '127.0.0.1',
'port' => 6660, 'port' => 6660,
'linger' => 500, 'linger' => 500,
], $listenerConf); ], $app['conf']->get(['task-manager', 'listener'], []));
}); });
$app['task-manager.job-factory'] = $app->share(function (Application $app) { $app['task-manager.job-factory'] = $app->share(function (Application $app) {
@@ -55,7 +49,7 @@ class TasksServiceProvider implements ServiceProviderInterface
}); });
$app['task-manager.status'] = $app->share(function (Application $app) { $app['task-manager.status'] = $app->share(function (Application $app) {
return new TaskManagerStatus($app['configuration']); return new TaskManagerStatus($app['configuration.store']);
}); });
$app['task-manager.live-information'] = $app->share(function (Application $app) { $app['task-manager.live-information'] = $app->share(function (Application $app) {

View File

@@ -48,7 +48,7 @@ class XSendFileFactory
*/ */
public static function create(Application $app) public static function create(Application $app)
{ {
$conf = $app['configuration']['xsendfile']; $conf = $app['conf']->get('xsendfile');
$mapping = []; $mapping = [];

View File

@@ -161,7 +161,7 @@ class PhraseaEngine implements SearchEngineInterface
return $this; return $this;
} }
$connexion = $this->app['configuration']['main']['database']; $connexion = $this->app['conf']->get(['main', 'database']);
$hostname = $connexion['host']; $hostname = $connexion['host'];
$port = (int) $connexion['port']; $port = (int) $connexion['port'];
@@ -228,7 +228,7 @@ class PhraseaEngine implements SearchEngineInterface
public function getConfigurationPanel() public function getConfigurationPanel()
{ {
if (!$this->configurationPanel) { if (!$this->configurationPanel) {
$this->configurationPanel = new ConfigurationPanel($this, $this->app['configuration']); $this->configurationPanel = new ConfigurationPanel($this, $this->app['configuration.store']);
} }
return $this->configurationPanel; return $this->configurationPanel;
@@ -556,7 +556,7 @@ class PhraseaEngine implements SearchEngineInterface
, $sbas_id , $sbas_id
, $this->colls[$sbas_id] , $this->colls[$sbas_id]
, $this->arrayq[$sbas_id] , $this->arrayq[$sbas_id]
, $this->app['configuration']['main']['key'] , $this->app['conf']->get(['main', 'key'])
, $this->app['session']->get('usr_id') , $this->app['session']->get('usr_id')
, false , false
, $this->options->getSearchType() == SearchEngineOptions::RECORD_GROUPING ? PHRASEA_MULTIDOC_REGONLY : PHRASEA_MULTIDOC_DOCONLY , $this->options->getSearchType() == SearchEngineOptions::RECORD_GROUPING ? PHRASEA_MULTIDOC_REGONLY : PHRASEA_MULTIDOC_DOCONLY

View File

@@ -175,7 +175,7 @@ class SphinxSearchEngine implements SearchEngineInterface
public function getConfigurationPanel() public function getConfigurationPanel()
{ {
if (!$this->configurationPanel) { if (!$this->configurationPanel) {
$this->configurationPanel = new ConfigurationPanel($this, $this->app['configuration']); $this->configurationPanel = new ConfigurationPanel($this, $this->app['configuration.store']);
} }
return $this->configurationPanel; return $this->configurationPanel;

View File

@@ -81,7 +81,7 @@ class ConfigurationTester
*/ */
public function isInstalled() public function isInstalled()
{ {
return $this->app['configuration']->isSetup(); return $this->app['configuration.store']->isSetup();
} }
/** /**

View File

@@ -104,7 +104,7 @@ class Installer
$this->app['manipulator.task']->create( $this->app['manipulator.task']->create(
$job->getName(), $job->getName(),
$job->getJobId(), $job->getJobId(),
$job->getEditor()->getDefaultSettings($this->app['configuration']), $job->getEditor()->getDefaultSettings($this->app['configuration.store']),
$job->getEditor()->getDefaultPeriod() $job->getEditor()->getDefaultPeriod()
); );
} }
@@ -152,7 +152,7 @@ class Installer
} }
} }
$this->app['configuration']->delete(); $this->app['configuration.store']->delete();
return; return;
} }
@@ -176,7 +176,7 @@ class Installer
private function createConfigFile($abConn, $serverName, $binaryData) private function createConfigFile($abConn, $serverName, $binaryData)
{ {
$config = $this->app['configuration']->initialize(); $config = $this->app['configuration.store']->initialize();
foreach ($abConn->get_credentials() as $key => $value) { foreach ($abConn->get_credentials() as $key => $value) {
$key = $key == 'hostname' ? 'host' : $key; $key = $key == 'hostname' ? 'host' : $key;
@@ -192,6 +192,6 @@ class Installer
$config['main']['key'] = md5(mt_rand(100000000, 999999999)); $config['main']['key'] = md5(mt_rand(100000000, 999999999));
$this->app['phraseanet.registry']->setKey($config['main']['key']); $this->app['phraseanet.registry']->setKey($config['main']['key']);
$this->app['configuration']->setConfig($config); $this->app['configuration.store']->setConfig($config);
} }
} }

View File

@@ -39,6 +39,6 @@ class BinariesProbe extends BinariesRequirements implements ProbeInterface
*/ */
public static function create(Application $app) public static function create(Application $app)
{ {
return new static($app['configuration']['binaries']); return new static($app['conf']->get('binaries'));
} }
} }

View File

@@ -29,7 +29,7 @@ class Migration35 implements MigrationInterface
throw new \LogicException('Required config files not found'); throw new \LogicException('Required config files not found');
} }
$config = $this->app['configuration']->initialize(); $config = $this->app['configuration.store']->initialize();
foreach ($config['registration-fields'] as $key => $field) { foreach ($config['registration-fields'] as $key => $field) {
$config['registration-fields'][$key]['required'] = (boolean) $field['required']; $config['registration-fields'][$key]['required'] = (boolean) $field['required'];
@@ -67,6 +67,6 @@ class Migration35 implements MigrationInterface
rename(__DIR__ . '/../../../../../../config/connexion.inc', __DIR__ . '/../../../../../../config/connexion.inc.old'); rename(__DIR__ . '/../../../../../../config/connexion.inc', __DIR__ . '/../../../../../../config/connexion.inc.old');
rename(__DIR__ . '/../../../../../../config/config.inc', __DIR__ . '/../../../../../../config/config.inc.old'); rename(__DIR__ . '/../../../../../../config/config.inc', __DIR__ . '/../../../../../../config/config.inc.old');
$this->app['configuration']->setConfig($config); $this->app['configuration.store']->setConfig($config);
} }
} }

View File

@@ -49,14 +49,14 @@ class Migration38 implements MigrationInterface
private function doMigrate($app) private function doMigrate($app)
{ {
$app['configuration']->initialize(); $app['configuration.store']->initialize();
$conf = $app['configuration']->getConfig(); $conf = $app['configuration.store']->getConfig();
$this->migrateConnexions($conf); $this->migrateConnexions($conf);
$this->migrateConfigAndServices($conf); $this->migrateConfigAndServices($conf);
$this->migrateBinaries($conf); $this->migrateBinaries($conf);
$app['configuration']->setConfig($conf); $app['configuration.store']->setConfig($conf);
foreach ([ foreach ([
$this->configYaml, $this->configYaml,

View File

@@ -79,7 +79,7 @@ class PhraseanetIndexerJob extends AbstractJob
private function getPhraseanetIndexerPath(Application $app) private function getPhraseanetIndexerPath(Application $app)
{ {
$binaries = $app['configuration']['binaries']; $binaries = $app['conf']->get('binaries');
if (isset($binaries['phraseanet_indexer'])) { if (isset($binaries['phraseanet_indexer'])) {
$path = $binaries['phraseanet_indexer']; $path = $binaries['phraseanet_indexer'];

View File

@@ -1478,7 +1478,7 @@ class ACL implements cache_cacheableInterface
foreach ($this->get_granted_base([], [$databox->get_sbas_id()]) as $collection) { foreach ($this->get_granted_base([], [$databox->get_sbas_id()]) as $collection) {
$stmt->execute([ $stmt->execute([
':site_id' => $this->app['configuration']['main']['key'], ':site_id' => $this->app['conf']->get(['main', 'key']),
':usr_id' => $this->user->get_id(), ':usr_id' => $this->user->get_id(),
':coll_id' => $collection->get_coll_id(), ':coll_id' => $collection->get_coll_id(),
':mask_and' => $this->get_mask_and($collection->get_base_id()), ':mask_and' => $this->get_mask_and($collection->get_base_id()),
@@ -1506,7 +1506,7 @@ class ACL implements cache_cacheableInterface
$sql = 'DELETE FROM collusr WHERE usr_id = :usr_id AND site = :site'; $sql = 'DELETE FROM collusr WHERE usr_id = :usr_id AND site = :site';
$params = [ $params = [
':usr_id' => $this->user->get_id() ':usr_id' => $this->user->get_id()
, ':site' => $this->app['configuration']['main']['key'] , ':site' => $this->app['conf']->get(['main', 'key'])
]; ];
$stmt = $databox->get_connection()->prepare($sql); $stmt = $databox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);

View File

@@ -310,9 +310,9 @@ class API_V1_adapter extends API_V1_Abstract
$ret['phraseanet']['environment'] = $app->getEnvironment(); $ret['phraseanet']['environment'] = $app->getEnvironment();
$ret['phraseanet']['debug'] = $app['debug']; $ret['phraseanet']['debug'] = $app['debug'];
$ret['phraseanet']['maintenance'] = $app['configuration']['main']['maintenance']; $ret['phraseanet']['maintenance'] = $app['conf']->get(['main', 'maintenance']);
$ret['phraseanet']['errorsLog'] = $app['debug']; $ret['phraseanet']['errorsLog'] = $app['debug'];
$ret['phraseanet']['serverName'] = $app['configuration']['main']['servername']; $ret['phraseanet']['serverName'] = $app['conf']->get(['main', 'servername']);
return $ret; return $ret;
} }
@@ -330,7 +330,7 @@ class API_V1_adapter extends API_V1_Abstract
$SEStatus = ['error' => $e->getMessage()]; $SEStatus = ['error' => $e->getMessage()];
} }
$binaries = $app['configuration']['binaries']; $binaries = $app['conf']->get('binaries');
return [ return [
'global_values' => [ 'global_values' => [
@@ -341,13 +341,13 @@ class API_V1_adapter extends API_V1_Abstract
'httpServer' => [ 'httpServer' => [
'logErrors' => $app['phraseanet.registry']->get('GV_log_errors'), 'logErrors' => $app['phraseanet.registry']->get('GV_log_errors'),
'phpTimezone' => ini_get('date.timezone'), 'phpTimezone' => ini_get('date.timezone'),
'siteId' => $app['configuration']['main']['key'], 'siteId' => $app['conf']->get(['main', 'key']),
'staticUrl' => $app['phraseanet.registry']->get('GV_STATIC_URL'), 'staticUrl' => $app['phraseanet.registry']->get('GV_STATIC_URL'),
'defaultLanguage' => $app['phraseanet.registry']->get('id_GV_default_lng'), 'defaultLanguage' => $app['phraseanet.registry']->get('id_GV_default_lng'),
'allowIndexing' => $app['phraseanet.registry']->get('GV_allow_search_engine'), 'allowIndexing' => $app['phraseanet.registry']->get('GV_allow_search_engine'),
'modes' => [ 'modes' => [
'XsendFile' => $app['configuration']['xsendfile']['enabled'], 'XsendFile' => $app['conf']->get(['xsendfile', 'enabled']),
'XsendFileMapping' => $app['configuration']['xsendfile']['mapping'], 'XsendFileMapping' => $app['conf']->get(['xsendfile', 'mapping']),
'h264Streaming' => $app['phraseanet.registry']->get('GV_h264_streaming'), 'h264Streaming' => $app['phraseanet.registry']->get('GV_h264_streaming'),
'authTokenDirectory' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory'), 'authTokenDirectory' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory'),
'authTokenDirectoryPath' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory_path'), 'authTokenDirectoryPath' => $app['phraseanet.registry']->get('GV_mod_auth_token_directory_path'),

View File

@@ -199,14 +199,12 @@ class API_V1_result
$this->app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent()); $this->app['dispatcher']->dispatch(PhraseaEvents::API_RESULT, new ApiResultEvent());
$conf = $this->app['configuration']; $conf = $this->app['configuration.store'];
if (isset($conf['main']['api-timers']) && true === $conf['main']['api-timers']) { if (isset($conf['main']['api-timers']) && true === $conf['main']['api-timers']) {
$ret['timers'] = $this->app['api.timers']->toArray(); $ret['timers'] = $this->app['api.timers']->toArray();
} }
$return_value = false;
switch ($this->response_type) { switch ($this->response_type) {
case self::FORMAT_JSON: case self::FORMAT_JSON:
default: default:

View File

@@ -121,7 +121,7 @@ class Session_Logger
$params = [ $params = [
':ses_id' => $app['session']->get('session_id'), ':ses_id' => $app['session']->get('session_id'),
':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_login() : null, ':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->get_login() : null,
':site_id' => $app['configuration']['main']['key'], ':site_id' => $app['conf']->get(['main', 'key']),
':usr_id' => $app['authentication']->isAuthenticated() ? $app['authentication']->getUser()->get_id() : null, ':usr_id' => $app['authentication']->isAuthenticated() ? $app['authentication']->getUser()->get_id() : null,
':browser' => $browser->getBrowser(), ':browser' => $browser->getBrowser(),
':browser_version' => $browser->getExtendedVersion(), ':browser_version' => $browser->getExtendedVersion(),
@@ -167,7 +167,7 @@ class Session_Logger
WHERE site = :site AND sit_session = :ses_id'; WHERE site = :site AND sit_session = :ses_id';
$params = [ $params = [
':site' => $app['configuration']['main']['key'] ':site' => $app['conf']->get(['main', 'key'])
, ':ses_id' => $app['session']->get('session_id') , ':ses_id' => $app['session']->get('session_id')
]; ];

View File

@@ -1057,12 +1057,12 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
} }
} }
if (isset($this->app['configuration']['user-settings'])) { if ($this->app['conf']->has('user-settings')) {
$this->_prefs = array_replace( $this->_prefs = array_replace(
$this->_prefs, $this->_prefs,
// remove keys that are not defined in default values // remove keys that are not defined in default values
array_intersect_key( array_intersect_key(
$this->app['configuration']['user-settings'], $this->app['conf']->get('user-settings'),
self::$def_values self::$def_values
) )
); );

View File

@@ -66,7 +66,7 @@ class appbox extends base
{ {
$this->app = $app; $this->app = $app;
$this->connection = connection::getPDOConnection($app); $this->connection = connection::getPDOConnection($app);
$connexion = $app['configuration']['main']['database']; $connexion = $app['conf']->get(['main', 'database']);
$this->host = $connexion['host']; $this->host = $connexion['host'];
$this->port = $connexion['port']; $this->port = $connexion['port'];

View File

@@ -129,7 +129,7 @@ class connection
if (trim($name) !== 'appbox') { if (trim($name) !== 'appbox') {
$connection_params = phrasea::sbas_params($app); $connection_params = phrasea::sbas_params($app);
} else { } else {
$connexion = $app['configuration']['main']['database']; $connexion = $app['conf']->get(['main', 'database']);
$hostname = $connexion['host']; $hostname = $connexion['host'];
$port = $connexion['port']; $port = $connexion['port'];

View File

@@ -462,7 +462,7 @@ class databox extends base
$this->app['EM']->flush(); $this->app['EM']->flush();
$params = [':site_id' => $this->app['configuration']['main']['key']]; $params = [':site_id' => $this->app['conf']->get(['main', 'key'])];
$sql = 'DELETE FROM clients WHERE site_id = :site_id'; $sql = 'DELETE FROM clients WHERE site_id = :site_id';
$stmt = $this->get_connection()->prepare($sql); $stmt = $this->get_connection()->prepare($sql);

View File

@@ -167,7 +167,7 @@ class module_console_checkExtension extends Command
, $base["sbas_id"] , $base["sbas_id"]
, $base["searchcoll"] , $base["searchcoll"]
, $base["arrayq"] , $base["arrayq"]
, $this->container['configuration']['main']['key'] , $this->container['conf']->get(['main', 'key'])
, $usrId , $usrId
, false , false
, PHRASEA_MULTIDOC_DOCONLY , PHRASEA_MULTIDOC_DOCONLY

View File

@@ -624,7 +624,7 @@ class module_report_activity extends module_report
$result['top_ten_poiddoc'] = []; $result['top_ten_poiddoc'] = [];
$result['top_ten_poidprev'] = []; $result['top_ten_poidprev'] = [];
$params = [':site_id' => $app['configuration']['main']['key']]; $params = [':site_id' => $app['conf']->get(['main', 'key'])];
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$params = array_merge($params, $datefilter['params']); $params = array_merge($params, $datefilter['params']);
@@ -704,7 +704,7 @@ class module_report_activity extends module_report
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = [':site_id' => $app['configuration']['main']['key']]; $params = [':site_id' => $app['conf']->get(['main', 'key'])];
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "
@@ -751,7 +751,7 @@ class module_report_activity extends module_report
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = [':site_id' => $app['configuration']['main']['key']]; $params = [':site_id' => $app['conf']->get(['main', 'key'])];
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "
@@ -792,7 +792,7 @@ class module_report_activity extends module_report
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = [':site_id' => $app['configuration']['main']['key']]; $params = [':site_id' => $app['conf']->get(['main', 'key'])];
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "
@@ -832,7 +832,7 @@ class module_report_activity extends module_report
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = [':site_id' => $app['configuration']['main']['key']]; $params = [':site_id' => $app['conf']->get(['main', 'key'])];
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "

View File

@@ -141,7 +141,7 @@ class module_report_connexion extends module_report
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge([ $params = array_merge([
':site_id' => $app['configuration']['main']['key'] ':site_id' => $app['conf']->get(['main', 'key'])
], ],
$datefilter['params'], $datefilter['params'],
$collfilter['params'] $collfilter['params']

View File

@@ -174,7 +174,7 @@ class module_report_download extends module_report
{ {
$conn = connection::getPDOConnection($app, $sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$params = [':site_id' => $app['configuration']['main']['key']]; $params = [':site_id' => $app['conf']->get(['main', 'key'])];
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -210,7 +210,7 @@ class module_report_download extends module_report
$databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id); $databox = $app['phraseanet.appbox']->get_databox((int) $sbas_id);
$conn = $databox->get_connection(); $conn = $databox->get_connection();
$params = [':site_id' => $app['configuration']['main']['key']]; $params = [':site_id' => $app['conf']->get(['main', 'key'])];
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);

View File

@@ -64,7 +64,7 @@ class module_report_sqlfilter
{ {
$finalfilter = ''; $finalfilter = '';
$params = [':log_site' => $this->app['configuration']['main']['key']]; $params = [':log_site' => $this->app['conf']->get(['main', 'key'])];
if ($this->filter['date']) { if ($this->filter['date']) {
$finalfilter .= $this->filter['date']['sql'] . ' AND '; $finalfilter .= $this->filter['date']['sql'] . ' AND ';
@@ -88,7 +88,7 @@ class module_report_sqlfilter
$params = []; $params = [];
$sql = 'log.site = :log_site_gv_filter'; $sql = 'log.site = :log_site_gv_filter';
$params[':log_site_gv_filter'] = $this->app['configuration']['main']['key']; $params[':log_site_gv_filter'] = $this->app['conf']->get(['main', 'key']);
return ['sql' => $sql, 'params' => $params]; return ['sql' => $sql, 'params' => $params];
} }

View File

@@ -56,7 +56,7 @@ class patch_370alpha9a implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$app['configuration']->setDefault('border-manager'); $app['configuration.store']->setDefault('border-manager');
return true; return true;
} }

View File

@@ -96,7 +96,7 @@ class patch_373alpha1a implements patchInterface
$stmt->closeCursor(); $stmt->closeCursor();
$config = $app['configuration']->getConfig(); $config = $app['configuration.store']->getConfig();
$config['binaries'] = $binaries; $config['binaries'] = $binaries;
$sql = 'DELETE FROM registry WHERE `key` = :key'; $sql = 'DELETE FROM registry WHERE `key` = :key';
@@ -116,7 +116,7 @@ class patch_373alpha1a implements patchInterface
$config['main']['key'] = $row['value']; $config['main']['key'] = $row['value'];
$app['configuration']->setConfig($config); $app['configuration.store']->setConfig($config);
$sql = 'DELETE FROM registry WHERE `key` = :key'; $sql = 'DELETE FROM registry WHERE `key` = :key';
$stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql); $stmt = $app['phraseanet.appbox']->get_connection()->prepare($sql);

View File

@@ -59,9 +59,7 @@ class patch_380alpha13a implements patchInterface
$xsendfilePath = $app['phraseanet.registry']->get('GV_X_Accel_Redirect'); $xsendfilePath = $app['phraseanet.registry']->get('GV_X_Accel_Redirect');
$xsendfileMountPoint = $app['phraseanet.registry']->get('GV_X_Accel_Redirect_mount_point'); $xsendfileMountPoint = $app['phraseanet.registry']->get('GV_X_Accel_Redirect_mount_point');
$config = $app['configuration'] $config = $app['configuration.store']->setDefault('xsendfile')->getConfig();
->setDefault('xsendfile')
->getConfig();
$config['xsendfile']['enabled'] = (Boolean) $app['phraseanet.registry']->get('GV_modxsendfile', false); $config['xsendfile']['enabled'] = (Boolean) $app['phraseanet.registry']->get('GV_modxsendfile', false);
$config['xsendfile']['type'] = $config['xsendfile']['enabled'] ? 'nginx' : ''; $config['xsendfile']['type'] = $config['xsendfile']['enabled'] ? 'nginx' : '';
@@ -73,7 +71,7 @@ class patch_380alpha13a implements patchInterface
]]; ]];
} }
$app['configuration']->setConfig($config); $app['configuration.store']->setConfig($config);
$toRemove = ['GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile']; $toRemove = ['GV_X_Accel_Redirect', 'GV_X_Accel_Redirect_mount_point', 'GV_modxsendfile'];

View File

@@ -56,7 +56,7 @@ class patch_380alpha14a implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$app['configuration']->setDefault('plugins'); $app['configuration.store']->setDefault('plugins');
return true; return true;
} }

View File

@@ -56,9 +56,8 @@ class patch_380alpha15a implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$binaries = $app['configuration']['binaries']; $app['conf']->remove(['binaries', 'composite_binary']);
unset($binaries['composite_binary'], $binaries['convert_binary']); $app['conf']->remove(['binaries', 'convert_binary']);
$app['configuration']['binaries'] = $binaries;
return true; return true;
} }

View File

@@ -56,7 +56,7 @@ class patch_380alpha16a implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$xsendfile = $app['configuration']['xsendfile']; $xsendfile = $app['conf']->get('xsendfile');
if (!isset($xsendfile['mapping'])) { if (!isset($xsendfile['mapping'])) {
$xsendfile['mapping'] = []; $xsendfile['mapping'] = [];
@@ -71,7 +71,7 @@ class patch_380alpha16a implements patchInterface
'mount-point' => '/download/', 'mount-point' => '/download/',
]; ];
$app['configuration']['xsendfile'] = $xsendfile; $app['conf']->set('xsendfile', $xsendfile);
return true; return true;
} }

View File

@@ -56,7 +56,7 @@ class patch_380alpha17a implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$auth = $app['configuration']['authentication']; $auth = $app['conf']->get('authentication');
if (isset($auth['captcha']) && isset($auth['captcha']['trials-before-failure'])) { if (isset($auth['captcha']) && isset($auth['captcha']['trials-before-failure'])) {
$auth['captcha']['trials-before-display'] = $auth['captcha']['trials-before-failure']; $auth['captcha']['trials-before-display'] = $auth['captcha']['trials-before-failure'];
@@ -67,7 +67,7 @@ class patch_380alpha17a implements patchInterface
unset($auth['auto-create']['enabled']); unset($auth['auto-create']['enabled']);
} }
$app['configuration']['authentication'] = $auth; $app['conf']->set('authentication', $auth);
return true; return true;
} }

View File

@@ -57,11 +57,7 @@ class patch_380alpha18a implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$finder = new ExecutableFinder(); $app['conf']->set(['binaries', 'recess_binary'], (new ExecutableFinder())->find('recess'));
$binaries = $app['configuration']['binaries'];
$binaries['recess_binary'] = $finder->find('recess');
$app['configuration']['binaries'] = $binaries;
return true; return true;
} }

View File

@@ -11,6 +11,11 @@
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
/**
*
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com
*/
class patch_380alpha2a implements patchInterface class patch_380alpha2a implements patchInterface
{ {
/** @var string */ /** @var string */
@@ -56,14 +61,8 @@ class patch_380alpha2a implements patchInterface
*/ */
public function apply(base $databox, Application $app) public function apply(base $databox, Application $app)
{ {
$config = $app['configuration']->getConfig(); if ($app['conf']->has(['main', 'database-test'])) {
$app['conf']->set(['main', 'database-test', 'path'], '/tmp/db.sqlite');
if (isset($config['main']['database-test'])) {
$config['main']['database-test']['path'] = '/tmp/db.sqlite';
} }
$app['configuration']->setConfig($config);
return true;
} }
} }

View File

@@ -56,7 +56,7 @@ class patch_380alpha3b implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$app['configuration']->setDefault('main', 'search-engine'); $app['configuration.store']->setDefault('main', 'search-engine');
return true; return true;
} }

View File

@@ -56,8 +56,8 @@ class patch_380alpha6a implements patchInterface
*/ */
public function apply(base $appbox, Application $app) public function apply(base $appbox, Application $app)
{ {
$app['configuration']->setDefault('registration-fields'); $app['configuration.store']->setDefault('registration-fields');
$app['configuration']->setDefault('authentication'); $app['configuration.store']->setDefault('authentication');
return true; return true;
} }

View File

@@ -73,9 +73,7 @@ class patch_380alpha8a implements patchInterface
$sxe = simplexml_load_string($row['settings']); $sxe = simplexml_load_string($row['settings']);
$indexer = $sxe->binpath . '/phraseanet_indexer'; $indexer = $sxe->binpath . '/phraseanet_indexer';
$binaries = $app['configuration']['binaries']; $app['conf']->set(['binaries', 'phraseanet_indexer'], $indexer);
$binaries['phraseanet_indexer'] = $indexer;
$app['configuration']['binaries'] = $binaries;
return true; return true;
} }

View File

@@ -1921,7 +1921,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
ORDER BY g.ord ASC, dateadd ASC, record_id ASC'; ORDER BY g.ord ASC, dateadd ASC, record_id ASC';
$params = [ $params = [
':GV_site' => $this->app['configuration']['main']['key'], ':GV_site' => $this->app['conf']->get(['main', 'key']),
':usr_id' => $this->app['authentication']->getUser()->get_id(), ':usr_id' => $this->app['authentication']->getUser()->get_id(),
':record_id' => $this->get_record_id(), ':record_id' => $this->get_record_id(),
]; ];
@@ -1972,7 +1972,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
WHERE rid_child = :record_id'; WHERE rid_child = :record_id';
$params = [ $params = [
':GV_site' => $this->app['configuration']['main']['key'] ':GV_site' => $this->app['conf']->get(['main', 'key'])
, ':usr_id' => $this->app['authentication']->getUser()->get_id() , ':usr_id' => $this->app['authentication']->getUser()->get_id()
, ':record_id' => $this->get_record_id() , ':record_id' => $this->get_record_id()
]; ];

View File

@@ -348,7 +348,7 @@ class record_preview extends record_adapter
if (! $report) { if (! $report) {
$sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")'; $sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")';
$params[':usr_id'] = $this->app['authentication']->getUser()->get_id(); $params[':usr_id'] = $this->app['authentication']->getUser()->get_id();
$params[':site'] = $this->app['configuration']['main']['key']; $params[':site'] = $this->app['conf']->get(['main', 'key']);
} }
$sql .= 'ORDER BY d.date, usrid DESC'; $sql .= 'ORDER BY d.date, usrid DESC';
@@ -453,7 +453,7 @@ class record_preview extends record_adapter
$stmt->execute( $stmt->execute(
[ [
':record_id' => $this->get_record_id(), ':record_id' => $this->get_record_id(),
':site' => $this->app['configuration']['main']['key'] ':site' => $this->app['conf']->get(['main', 'key'])
] ]
); );
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -614,7 +614,7 @@ class record_preview extends record_adapter
$stmt->execute( $stmt->execute(
[ [
':record_id' => $this->get_record_id(), ':record_id' => $this->get_record_id(),
':site' => $this->app['configuration']['main']['key'] ':site' => $this->app['conf']->get(['main', 'key'])
] ]
); );
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);

View File

@@ -47,13 +47,11 @@ class registry implements registryInterface
$this->cache = new ArrayCache(); $this->cache = new ArrayCache();
if ($app['phraseanet.configuration-tester']->isInstalled()) { if ($app['phraseanet.configuration-tester']->isInstalled()) {
$this->cache->save('GV_ServerName', $app['configuration']['main']['servername']); $this->cache->save('GV_ServerName', $app['conf']->get(['main', 'servername']));
$this->cache->save('GV_debug', $app['debug']); $this->cache->save('GV_debug', $app['debug']);
$config = $app['configuration']->getConfig(); if ($app['conf']->has(['main', 'key'])) {
$this->cache->save('GV_sit', $app['conf']->get(['main', 'key']));
if (isset($config['main']['key'])) {
$this->cache->save('GV_sit', $config['main']['key']);
} }
} }

View File

@@ -196,7 +196,7 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals($value, $response->headers->get($name)); $this->assertEquals($value, $response->headers->get($name));
} }
$this->assertEquals(rtrim(self::$DI['app']['configuration']['main']['servername'], '/') . "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token, $response->headers->get("Link")); $this->assertEquals(rtrim(self::$DI['app']['conf']->get(['main', 'servername']), '/') . "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token, $response->headers->get("Link"));
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }
@@ -238,7 +238,7 @@ class OverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->assertEquals($value, $response->headers->get($name)); $this->assertEquals($value, $response->headers->get($name));
} }
$this->assertEquals(rtrim(self::$DI['app']['configuration']['main']['servername'], '/') . "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token, $response->headers->get("Link")); $this->assertEquals(rtrim(self::$DI['app']['conf']->get(['main', 'servername']), '/') . "/permalink/v1/1/". self::$DI['record_1']->get_record_id()."/caption/?token=".$token, $response->headers->get("Link"));
$this->assertEquals(200, $response->getStatusCode()); $this->assertEquals(200, $response->getStatusCode());
} }

View File

@@ -291,14 +291,13 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract
public function testUrlGeneratorContext() public function testUrlGeneratorContext()
{ {
$app = new Application('test'); $app = new Application('test');
$app['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); $app['conf'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\PropertyAccess')
$app['configuration']->expects($this->once()) ->disableOriginalConstructor()
->method('isSetup') ->getMock();
->will($this->returnValue(true)); $app['conf']->expects($this->once())
$app['configuration']->expects($this->once()) ->method('get')
->method('offsetGet') ->with(['main', 'servername'])
->with('main') ->will($this->returnValue('https://cat.turbocat.com/'));
->will($this->returnValue(['servername' => 'https://cat.turbocat.com/']));
$this->assertEquals('https', $app['url_generator']->getContext()->getScheme()); $this->assertEquals('https', $app['url_generator']->getContext()->getScheme());
$this->assertEquals('cat.turbocat.com', $app['url_generator']->getContext()->getHost()); $this->assertEquals('cat.turbocat.com', $app['url_generator']->getContext()->getHost());

View File

@@ -11,8 +11,8 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
$command = new Configuration(); $command = new Configuration();
$command->setContainer(self::$DI['cli']); $command->setContainer(self::$DI['cli']);
self::$DI['cli']['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); self::$DI['cli']['configuration.store'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
self::$DI['cli']['configuration']->expects($this->once()) self::$DI['cli']['configuration.store']->expects($this->once())
->method('compileAndWrite'); ->method('compileAndWrite');
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $input = $this->getMock('Symfony\Component\Console\Input\InputInterface');

View File

@@ -1,6 +1,6 @@
<?php <?php
namespace Alchemy\Tests\Phrasea\Command; namespace Alchemy\Tests\Phrasea\Command\Setup;
use Alchemy\Phrasea\Command\Setup\XSendFileMappingGenerator; use Alchemy\Phrasea\Command\Setup\XSendFileMappingGenerator;
@@ -30,14 +30,17 @@ class XSendFileMappingGeneratorTest extends \PhraseanetPHPUnitAbstract
self::$DI['cli']['monolog'] = self::$DI['cli']->share(function () use ($phpunit) { self::$DI['cli']['monolog'] = self::$DI['cli']->share(function () use ($phpunit) {
return $phpunit->getMockBuilder('Monolog\Logger')->disableOriginalConstructor()->getMock(); return $phpunit->getMockBuilder('Monolog\Logger')->disableOriginalConstructor()->getMock();
}); });
self::$DI['cli']['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); self::$DI['cli']['conf'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\PropertyAccess')
->disableOriginalConstructor()
->getMock();
if ($option) { if ($option) {
self::$DI['cli']['configuration']->expects($this->once())
->method('offsetSet') self::$DI['cli']['conf']->expects($this->once())
->method('set')
->with('xsendfile'); ->with('xsendfile');
} else { } else {
self::$DI['cli']['configuration']->expects($this->never()) self::$DI['cli']['conf']->expects($this->never())
->method('offsetSet'); ->method('set');
} }
$command->setContainer(self::$DI['cli']); $command->setContainer(self::$DI['cli']);
@@ -49,6 +52,16 @@ class XSendFileMappingGeneratorTest extends \PhraseanetPHPUnitAbstract
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$logger = $this->getMockBuilder('Monolog\Logger')
->disableOriginalConstructor()
->getMock();
$logger->expects($this->once())
->method('error');
self::$DI['cli']['monolog'] = self::$DI['cli']->share(function () use ($logger) {
return $logger;
});
$input->expects($this->any()) $input->expects($this->any())
->method('getArgument') ->method('getArgument')
->with('type') ->with('type')

View File

@@ -9,7 +9,7 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
*/ */
public function testRouteMysql() public function testRouteMysql()
{ {
$connexion = self::$DI['app']['configuration']['main']['database']; $connexion = self::$DI['app']['conf']->get(['main', 'database']);
$params = [ $params = [
"hostname" => $connexion['host'], "hostname" => $connexion['host'],
@@ -26,7 +26,7 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
public function testRouteMysqlFailed() public function testRouteMysqlFailed()
{ {
$connexion = self::$DI['app']['configuration']['main']['database']; $connexion = self::$DI['app']['conf']->get(['main', 'database']);
$params = [ $params = [
"hostname" => $connexion['host'], "hostname" => $connexion['host'],
@@ -52,7 +52,7 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
public function testRouteMysqlDbFailed() public function testRouteMysqlDbFailed()
{ {
$connexion = self::$DI['app']['configuration']['main']['database']; $connexion = self::$DI['app']['conf']->get(['main', 'database']);
$params = [ $params = [
"hostname" => $connexion['host'], "hostname" => $connexion['host'],

View File

@@ -94,7 +94,7 @@ class PluginServiceProvidertest extends ServiceProviderTestCase
} }
$app = self::$DI['cli']; $app = self::$DI['cli'];
$app['configuration'] = ['binaries' => ['php_binary' => null]]; $app['conf']->set(['binaries', 'php_binary'], null);
$app->register(new PluginServiceProvider()); $app->register(new PluginServiceProvider());
$this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']); $this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']);
} }
@@ -102,7 +102,7 @@ class PluginServiceProvidertest extends ServiceProviderTestCase
public function testInstallerCanDetectPhpConf() public function testInstallerCanDetectPhpConf()
{ {
$app = self::$DI['cli']; $app = self::$DI['cli'];
$app['configuration'] = ['binaries' => ['php_binary' => null]]; $app['conf']->set(['binaries', 'php_binary'], null);
$app->register(new PluginServiceProvider()); $app->register(new PluginServiceProvider());
$this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']); $this->assertInstanceOf('Alchemy\Phrasea\Plugin\Management\ComposerInstaller', $app['plugins.composer-installer']);
} }

View File

@@ -30,7 +30,7 @@ class DebuggerSubscriberTest extends \PHPUnit_Framework_TestCase
unlink($app['phraseanet.configuration.config-compiled-path']); unlink($app['phraseanet.configuration.config-compiled-path']);
} }
$app['configuration']['debugger'] = ['allowed-ips' => $authorized]; $app['conf']->set(['debugger', 'allowed-ips'], $authorized);
$app['dispatcher']->addSubscriber(new DebuggerSubscriber($app)); $app['dispatcher']->addSubscriber(new DebuggerSubscriber($app));
$app->get('/', function () { $app->get('/', function () {
return 'success'; return 'success';

View File

@@ -110,7 +110,7 @@ class PhraseaLocaleSubscriberTest extends \PhraseanetPHPUnitAbstract
$app['phraseanet.registry'] = $this->getMockBuilder('\registry') $app['phraseanet.registry'] = $this->getMockBuilder('\registry')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getmock(); ->getmock();
$app['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); $app['configuration.store'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
$app['dispatcher']->addSubscriber(new PhraseaLocaleSubscriber($app)); $app['dispatcher']->addSubscriber(new PhraseaLocaleSubscriber($app));

View File

@@ -87,9 +87,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
$app->register(new AuthenticationManagerServiceProvider()); $app->register(new AuthenticationManagerServiceProvider());
$app->register(new ConfigurationServiceProvider()); $app->register(new ConfigurationServiceProvider());
$app['configuration'] = $conf = $app['configuration']->getConfig(); $app['conf']->set(['authentication', 'captcha', 'trials-before-display'], 42);
$conf['authentication']['captcha']['trials-before-display'] = 42;
$app['configuration'] = $conf;
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager') $app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
->disableOriginalConstructor() ->disableOriginalConstructor()
@@ -107,11 +105,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
$app = new PhraseaApplication(); $app = new PhraseaApplication();
$app->register(new ConfigurationServiceProvider()); $app->register(new ConfigurationServiceProvider());
$conf = $app['configuration']->getConfig(); $app['conf']->set(['authentication', 'auto-create'], ['templates' => []]);
$conf['authentication']['auto-create'] = [
'templates' => [],
];
$app['configuration']->setConfig($conf);
$app['authentication.providers.account-creator']; $app['authentication.providers.account-creator'];
} }
@@ -138,11 +132,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
})); }));
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox']; $app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
$conf = $app['configuration']->getConfig(); $app['conf']->set(['authentication', 'captcha'], ['enabled' => true]);
$conf['authentication']['captcha'] = [
'enabled' => true,
];
$app['configuration']->setConfig($conf);
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager') $app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
->disableOriginalConstructor() ->disableOriginalConstructor()
@@ -176,11 +166,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
})); }));
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox']; $app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
$conf = $app['configuration']->getConfig(); $app['conf']->set(['authentication', 'captcha'], ['enabled' => false]);
$conf['authentication']['captcha'] = [
'enabled' => false,
];
$app['configuration']->setConfig($conf);
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager') $app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
->disableOriginalConstructor() ->disableOriginalConstructor()
@@ -202,14 +188,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
$template2 = \User_Adapter::create(self::$DI['app'], 'template' . $random->generatePassword(), $random->generatePassword(), null, false); $template2 = \User_Adapter::create(self::$DI['app'], 'template' . $random->generatePassword(), $random->generatePassword(), null, false);
$template2->set_template(self::$DI['user']); $template2->set_template(self::$DI['user']);
$conf = $app['configuration']->getConfig(); $app['conf']->set(['authentication', 'auto-create'], ['templates' => [$template1->get_id(), $template2->get_login()]]);
$conf['authentication']['auto-create'] = [
'templates' => [
$template1->get_id(),
$template2->get_login()
]
];
$app['configuration']->setConfig($conf);
$this->assertEquals([$template1, $template2], $app['authentication.providers.account-creator']->getTemplates()); $this->assertEquals([$template1, $template2], $app['authentication.providers.account-creator']->getTemplates());

View File

@@ -3,6 +3,7 @@
namespace Alchemy\Tests\Phrasea\Core\Provider; namespace Alchemy\Tests\Phrasea\Core\Provider;
use Alchemy\Phrasea\Core\Provider\BorderManagerServiceProvider; use Alchemy\Phrasea\Core\Provider\BorderManagerServiceProvider;
use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider;
use Silex\Application; use Silex\Application;
use Symfony\Component\Process\ExecutableFinder; use Symfony\Component\Process\ExecutableFinder;
use XPDF\XPDFServiceProvider; use XPDF\XPDFServiceProvider;
@@ -32,7 +33,9 @@ class BorderManagerServiceProvidertest extends ServiceProviderTestCase
] ]
]); ]);
$app->register(new BorderManagerServiceProvider()); $app->register(new BorderManagerServiceProvider());
$app['configuration'] = ['border-manager' => ['enabled' => false]]; $app['root.path'] = __DIR__ . '/../../../../../..';
$app->register(new ConfigurationServiceProvider());
$app['conf']->set(['border-manager', 'enabled'], false);
$this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']); $this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']);
$this->assertNull($app['border-manager']->getPdfToText()); $this->assertNull($app['border-manager']->getPdfToText());
@@ -54,7 +57,9 @@ class BorderManagerServiceProvidertest extends ServiceProviderTestCase
] ]
]); ]);
$app->register(new BorderManagerServiceProvider()); $app->register(new BorderManagerServiceProvider());
$app['configuration'] = ['border-manager' => ['enabled' => false]]; $app['root.path'] = __DIR__ . '/../../../../../..';
$app->register(new ConfigurationServiceProvider());
$app['conf']->set(['border-manager', 'enabled'], false);
$this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']); $this->assertInstanceOf('Alchemy\Phrasea\Border\Manager', $app['border-manager']);
$this->assertInstanceOf('XPDF\PdfToText', $app['border-manager']->getPdfToText()); $this->assertInstanceOf('XPDF\PdfToText', $app['border-manager']->getPdfToText());

View File

@@ -17,7 +17,7 @@ class ConfigurationServiceProvidertest extends ServiceProviderTestCase
return [ return [
[ [
'Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider', 'Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider',
'configuration.storage', 'configuration.store',
'Alchemy\\Phrasea\\Core\\Configuration\\Configuration' 'Alchemy\\Phrasea\\Core\\Configuration\\Configuration'
], ],
[ [

View File

@@ -3,6 +3,7 @@
namespace Alchemy\Tests\Phrasea\Core\Provider; namespace Alchemy\Tests\Phrasea\Core\Provider;
use Alchemy\Phrasea\Application; use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider;
use Alchemy\Phrasea\Core\Provider\LocaleServiceProvider; use Alchemy\Phrasea\Core\Provider\LocaleServiceProvider;
/** /**
@@ -22,18 +23,9 @@ class LocaleServiceProvidertest extends \PhraseanetPHPUnitAbstract
{ {
$app = new Application(); $app = new Application();
$app->register(new LocaleServiceProvider()); $app->register(new LocaleServiceProvider());
$app['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); $app['root.path'] = __DIR__ . '/../../../../../..';
$app['configuration']->expects($this->any()) $app->register(new ConfigurationServiceProvider());
->method('offsetExist') $app['conf']->set(['main', 'languages'], ['fr_FR', 'en_US', 'de']);
->with('main')
->will($this->returnValue(true));
$app['configuration']->expects($this->any())
->method('isSetup')
->will($this->returnValue(true));
$app['configuration']->expects($this->any())
->method('offsetGet')
->with('main')
->will($this->returnValue(['languages' => ['fr_FR', 'en_US', 'de']]));
$original = Application::getAvailableLanguages(); $original = Application::getAvailableLanguages();
unset($original['en_GB']); unset($original['en_GB']);
@@ -46,18 +38,11 @@ class LocaleServiceProvidertest extends \PhraseanetPHPUnitAbstract
{ {
$app = new Application(); $app = new Application();
$app->register(new LocaleServiceProvider()); $app->register(new LocaleServiceProvider());
$app['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); $app['root.path'] = __DIR__ . '/../../../../../..';
$app['configuration']->expects($this->any()) $app->register(new ConfigurationServiceProvider());
->method('offsetExist')
->with('main') $app['conf']->set(['main', 'languages'], ['en_US']);
->will($this->returnValue(true));
$app['configuration']->expects($this->any())
->method('isSetup')
->will($this->returnValue(true));
$app['configuration']->expects($this->any())
->method('offsetGet')
->with('main')
->will($this->returnValue(['languages' => ['en_US']]));
$app['monolog'] = $this->getMock('Psr\Log\LoggerInterface'); $app['monolog'] = $this->getMock('Psr\Log\LoggerInterface');
$app['monolog']->expects($this->once()) $app['monolog']->expects($this->once())
->method('error'); ->method('error');

View File

@@ -12,10 +12,7 @@ class RegistrationServiceProvidertest extends \PhraseanetPHPUnitAbstract
public function testSameInstanceShouldBereturnedEveryTime() public function testSameInstanceShouldBereturnedEveryTime()
{ {
self::$DI['app']->register(new RegistrationServiceProvider()); self::$DI['app']->register(new RegistrationServiceProvider());
self::$DI['app']['conf']->set('registration-fields', ['plop']);
$conf = self::$DI['app']['configuration']->getConfig();
$conf['registration-fields'] = ['plop'];
self::$DI['app']['configuration'] = $conf;
$this->assertEquals(['plop'], self::$DI['app']['registration.fields']); $this->assertEquals(['plop'], self::$DI['app']['registration.fields']);
$this->assertEquals(['plop'], self::$DI['app']['registration.fields']); $this->assertEquals(['plop'], self::$DI['app']['registration.fields']);

View File

@@ -18,6 +18,6 @@ class PhraseaConfigurationPanelTest extends ConfigurationPanelAbstractTest
public function getPanel() public function getPanel()
{ {
return new ConfigurationPanel(new PhraseaEngine(self::$DI['app']), self::$DI['app']['configuration']); return new ConfigurationPanel(new PhraseaEngine(self::$DI['app']), self::$DI['app']['configuration.store']);
} }
} }

View File

@@ -18,7 +18,7 @@ class SphinxSearchConfigurationPanelTest extends ConfigurationPanelAbstractTest
public function getPanel() public function getPanel()
{ {
return new ConfigurationPanel(new SphinxSearchEngine(self::$DI['app'], 'localhost', 9306, 'localhost', 9308), self::$DI['app']['configuration']); return new ConfigurationPanel(new SphinxSearchEngine(self::$DI['app'], 'localhost', 9306, 'localhost', 9308), self::$DI['app']['configuration.store']);
} }
public function testGetAVailableCharsets() public function testGetAVailableCharsets()

View File

@@ -35,16 +35,14 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest
$app = new Application('test'); $app = new Application('test');
$appbox = $app['phraseanet.appbox']; $appbox = $app['phraseanet.appbox'];
$configuration = $app['configuration']->getConfig(); $app['conf']->set(['main', 'search-engine', 'options'], [
$configuration['main']['search-engine']['options'] = [
'host' => '127.0.0.1', 'host' => '127.0.0.1',
'port' => 9312, 'port' => 9312,
'rt_host' => '127.0.0.1', 'rt_host' => '127.0.0.1',
'rt_port' => 9306, 'rt_port' => 9306,
]; ]);
$app['configuration']->setConfig($configuration);
self::$searchEngine = SphinxSearchEngine::create($app, $app['configuration']['main']['search-engine']['options']); self::$searchEngine = SphinxSearchEngine::create($app, $app['conf']->get(['main', 'search-engine', 'options']));
self::$config = tempnam(sys_get_temp_dir(), 'tmp_sphinx.conf'); self::$config = tempnam(sys_get_temp_dir(), 'tmp_sphinx.conf');
$configuration = self::$searchEngine->getConfigurationPanel()->getConfiguration(); $configuration = self::$searchEngine->getConfigurationPanel()->getConfiguration();
@@ -73,7 +71,7 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest
self::$searchd = new Process($searchd . ' -c ' . self::$config); self::$searchd = new Process($searchd . ' -c ' . self::$config);
self::$searchd->run(); self::$searchd->run();
self::$searchEngine = SphinxSearchEngine::create($app, $app['configuration']['main']['search-engine']['options']); self::$searchEngine = SphinxSearchEngine::create($app, $app['conf']->get(['main', 'search-engine', 'options']));
} }
public function setUp() public function setUp()

View File

@@ -51,7 +51,7 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
@unlink($config); @unlink($config);
@unlink($compiled); @unlink($compiled);
$app['configuration'] = new Configuration(new Yaml(), new Compiler(), $config, $compiled, true); $app['configuration.store'] = new Configuration(new Yaml(), new Compiler(), $config, $compiled, true);
$abConn = new \connection_pdo('abConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'ab_unitTests'); $abConn = new \connection_pdo('abConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'ab_unitTests');
$dbConn = new \connection_pdo('dbConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'db_unitTests'); $dbConn = new \connection_pdo('dbConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'db_unitTests');
@@ -64,14 +64,14 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
\User_Adapter::unsetInstances(); \User_Adapter::unsetInstances();
$this->assertTrue($app['configuration']->isSetup()); $this->assertTrue($app['configuration.store']->isSetup());
$this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate()); $this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
$databoxes = $app['phraseanet.appbox']->get_databoxes(); $databoxes = $app['phraseanet.appbox']->get_databoxes();
$databox = array_pop($databoxes); $databox = array_pop($databoxes);
$this->assertContains('<path>'.realpath($dataPath).'/db_unitTests/subdefs</path>', $databox->get_structure()); $this->assertContains('<path>'.realpath($dataPath).'/db_unitTests/subdefs</path>', $databox->get_structure());
$conf = $app['configuration']->getConfig(); $conf = $app['configuration.store']->getConfig();
$this->assertArrayHasKey('main', $conf); $this->assertArrayHasKey('main', $conf);
$this->assertArrayHasKey('key', $conf['main']); $this->assertArrayHasKey('key', $conf['main']);
$this->assertGreaterThan(10, strlen($conf['main']['key'])); $this->assertGreaterThan(10, strlen($conf['main']['key']));

View File

@@ -62,7 +62,7 @@ class Migration35Test extends AbstractSetupTester
$app = $app ? : new Application('test'); $app = $app ? : new Application('test');
if ($this->specifications) { if ($this->specifications) {
$app['configuration'] = $this->specifications; $app['configuration.store'] = $this->specifications;
} }
return new Migration35($app); return new Migration35($app);

View File

@@ -30,17 +30,17 @@ class Migration38Test extends AbstractSetupTester
public function testMigrate() public function testMigrate()
{ {
$app = new Application(); $app = new Application();
$app['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); $app['configuration.store'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
$app['root.path'] = __DIR__ . '/../Probe/fixtures-3807'; $app['root.path'] = __DIR__ . '/../Probe/fixtures-3807';
$app['configuration']->expects($this->once()) $app['configuration.store']->expects($this->once())
->method('initialize'); ->method('initialize');
$app['configuration']->expects($this->once()) $app['configuration.store']->expects($this->once())
->method('getConfig') ->method('getConfig')
->will($this->returnValue($this->getCurrent())); ->will($this->returnValue($this->getCurrent()));
$app['configuration']->expects($this->once()) $app['configuration.store']->expects($this->once())
->method('setConfig') ->method('setConfig')
->with($this->getModified()); ->with($this->getModified());

View File

@@ -43,7 +43,7 @@ abstract class EditorTestCase extends \PhraseanetPHPUnitAbstract
$editor = $this->getEditor(); $editor = $this->getEditor();
$dom = new \DOMDocument(); $dom = new \DOMDocument();
$dom->strictErrorChecking = true; $dom->strictErrorChecking = true;
$this->assertTrue(false !== $dom->loadXML($editor->getDefaultSettings(self::$DI['app']['configuration']))); $this->assertTrue(false !== $dom->loadXML($editor->getDefaultSettings(self::$DI['app']['configuration.store'])));
} }
public function testGetDefaultSettingsWithoutConfiguration() public function testGetDefaultSettingsWithoutConfiguration()

View File

@@ -142,7 +142,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}); });
$app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) { $app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) {
$host = parse_url($app['configuration']['main']['servername'], PHP_URL_HOST); $host = parse_url($app['conf']->get(['main', 'servername']), PHP_URL_HOST);
$generator->setContext(new RequestContext('', 'GET', $host)); $generator->setContext(new RequestContext('', 'GET', $host));
return $generator; return $generator;
@@ -183,7 +183,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
}); });
$app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) { $app['url_generator'] = $app->share($app->extend('url_generator', function ($generator, $app) {
$host = parse_url($app['configuration']['main']['servername'], PHP_URL_HOST); $host = parse_url($app['conf']->get(['main', 'servername']), PHP_URL_HOST);
$generator->setContext(new RequestContext('', 'GET', $host)); $generator->setContext(new RequestContext('', 'GET', $host));
return $generator; return $generator;

View File

@@ -98,7 +98,7 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
{ {
$this->createDatabase(); $this->createDatabase();
$connexion = self::$DI['app']['configuration']['main']['database']; $connexion = self::$DI['app']['conf']->get(['main', 'database']);
try { try {
$conn = new \connection_pdo( $conn = new \connection_pdo(

View File

@@ -40,7 +40,7 @@ class Session_LoggerTest extends PhraseanetPHPUnitAbstract
$params = [ $params = [
':ses_id' => self::$DI['app']['session']->get('session_id') ':ses_id' => self::$DI['app']['session']->get('session_id')
, ':usr_id' => self::$DI['app']['authentication']->getUser()->get_id() , ':usr_id' => self::$DI['app']['authentication']->getUser()->get_id()
, ':site' => self::$DI['app']['configuration']['main']['key'] , ':site' => self::$DI['app']['conf']->get(['main', 'key'])
]; ];
$stmt = $this->databox->get_connection()->prepare($sql); $stmt = $this->databox->get_connection()->prepare($sql);
@@ -59,7 +59,7 @@ class Session_LoggerTest extends PhraseanetPHPUnitAbstract
$params = [ $params = [
':ses_id' => $ses_id ':ses_id' => $ses_id
, ':usr_id' => $usr_id , ':usr_id' => $usr_id
, ':site' => self::$DI['app']['configuration']['main']['key'] , ':site' => self::$DI['app']['conf']->get(['main', 'key'])
]; ];
$stmt = $this->databox->get_connection()->prepare($sql); $stmt = $this->databox->get_connection()->prepare($sql);

View File

@@ -16,10 +16,7 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract
parent::setUp(); parent::setUp();
self::$DI['app']->register(new \API_V1_Timer()); self::$DI['app']->register(new \API_V1_Timer());
self::$DI['app']['conf']->set(['main', 'api-timers'], true);
$conf = self::$DI['app']['configuration']->getConfig();
$conf['main']['api-timers'] = true;
self::$DI['app']['configuration']->setConfig($conf);
$this->api = $this->getMock("API_V1_adapter", ["get_version"], [], "", false); $this->api = $this->getMock("API_V1_adapter", ["get_version"], [], "", false);
$this->api->expects($this->any())->method("get_version")->will($this->returnValue("my_super_version1.0")); $this->api->expects($this->any())->method("get_version")->will($this->returnValue("my_super_version1.0"));

View File

@@ -15,8 +15,8 @@ class patch_380alpha3bTest extends PhraseanetPHPUnitAbstract
$app = self::$DI['app']; $app = self::$DI['app'];
$app['configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface'); $app['configuration.store'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
$app['configuration']->expects($this->once()) $app['configuration.store']->expects($this->once())
->method('setDefault') ->method('setDefault')
->with('main', 'search-engine'); ->with('main', 'search-engine');

View File

@@ -60,13 +60,13 @@ class userTest extends PhraseanetPHPUnitAbstract
public function testGetPrefWithACustomizedConf() public function testGetPrefWithACustomizedConf()
{ {
$data = isset(self::$DI['app']['configuration']['user-settings']) ? self::$DI['app']['configuration']['user-settings'] : null; $data = self::$DI['app']['conf']->get(['user-settings']);
self::$DI['app']['configuration']['user-settings'] = [ self::$DI['app']['conf']->set('user-settings', [
'images_per_page' => 42, 'images_per_page' => 42,
'images_size' => 666, 'images_size' => 666,
'lalala' => 'didou', 'lalala' => 'didou',
]; ]);
$user = $this->get_user(); $user = $this->get_user();
@@ -76,9 +76,9 @@ class userTest extends PhraseanetPHPUnitAbstract
$this->assertSame(\User_Adapter::$def_values['editing_top_box'], $user->getPrefs('editing_top_box')); $this->assertSame(\User_Adapter::$def_values['editing_top_box'], $user->getPrefs('editing_top_box'));
if (null === $data) { if (null === $data) {
unset(self::$DI['app']['configuration']['user-settings']); self::$DI['app']['conf']->remove('user-settings');
} else { } else {
self::$DI['app']['configuration']['user-settings'] = $data; self::$DI['app']['conf']->set('user-settings', $data);
} }
} }