Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce a configuration manager #570

Merged
merged 13 commits into from
Jul 9, 2016
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions application/ApplicationUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ public static function checkPHPVersion($minVersion, $curVersion)
/**
* Checks Shaarli has the proper access permissions to its resources
*
* @param array $globalConfig The $GLOBALS['config'] array
* @param ConfigManager $conf Configuration Manager instance.
*
* @return array A list of the detected configuration issues
*/
public static function checkResourcePermissions($globalConfig)
public static function checkResourcePermissions($conf)
{
$errors = array();

Expand All @@ -145,7 +145,7 @@ public static function checkResourcePermissions($globalConfig)
'application',
'inc',
'plugins',
$globalConfig['RAINTPL_TPL']
$conf->get('resource.raintpl_tpl'),
) as $path) {
if (! is_readable(realpath($path))) {
$errors[] = '"'.$path.'" directory is not readable';
Expand All @@ -154,10 +154,10 @@ public static function checkResourcePermissions($globalConfig)

// Check cache and data directories are readable and writeable
foreach (array(
$globalConfig['CACHEDIR'],
$globalConfig['DATADIR'],
$globalConfig['PAGECACHE'],
$globalConfig['RAINTPL_TMP']
$conf->get('resource.thumbnails_cache'),
$conf->get('resource.data_dir'),
$conf->get('resource.page_cache'),
$conf->get('resource.raintpl_tmp'),
) as $path) {
if (! is_readable(realpath($path))) {
$errors[] = '"'.$path.'" directory is not readable';
Expand All @@ -169,11 +169,11 @@ public static function checkResourcePermissions($globalConfig)

// Check configuration files are readable and writeable
foreach (array(
$globalConfig['CONFIG_FILE'],
$globalConfig['DATASTORE'],
$globalConfig['IPBANS_FILENAME'],
$globalConfig['LOG_FILE'],
$globalConfig['UPDATECHECK_FILENAME']
$conf->getConfigFileExt(),
$conf->get('resource.datastore'),
$conf->get('resource.ban_file'),
$conf->get('resource.log'),
$conf->get('resource.update_check'),
) as $path) {
if (! is_file(realpath($path))) {
# the file may not exist yet
Expand Down
221 changes: 0 additions & 221 deletions application/Config.php

This file was deleted.

8 changes: 5 additions & 3 deletions application/FileUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ class IOException extends Exception
/**
* Construct a new IOException
*
* @param string $path path to the ressource that cannot be accessed
* @param string $path path to the resource that cannot be accessed
* @param string $message Custom exception message.
*/
public function __construct($path)
public function __construct($path, $message = '')
{
$this->path = $path;
$this->message = 'Error accessing '.$this->path;
$this->message = empty($message) ? 'Error accessing' : $message;
$this->message .= PHP_EOL . $this->path;
}
}
Loading