Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2014-02-18 05:03:18 +0400
committermattab <matthieu.aubry@gmail.com>2014-02-18 05:03:18 +0400
commit39739583d8587fa339f7750afe658e263e31d841 (patch)
tree55b000c1aa4ab5b9cae5b23268b4f8eedf554bea
parentca55552567cd3127b9658fe93e4d288b8e23d8ee (diff)
Show helpful message when config file is not readable
-rwxr-xr-xconsole13
-rw-r--r--core/Console.php44
2 files changed, 42 insertions, 15 deletions
diff --git a/console b/console
index 065eb736b3..47912e1508 100755
--- a/console
+++ b/console
@@ -17,17 +17,6 @@ Translate::loadEnglishTranslation();
if (!Common::isPhpCliMode()) {
exit;
}
-
-$piwikHostname = CronArchive::getParameterFromCli('piwik-domain', true);
-$piwikHostname = UrlHelper::getHostFromUrl($piwikHostname);
-
-Url::setHost($piwikHostname);
-
-// load active plugins
-$pluginsManager = Plugin\Manager::getInstance();
-$pluginsToLoad = Config::getInstance()->Plugins['Plugins'];
-$pluginsManager->loadPlugins($pluginsToLoad);
-
-
$console = new Console();
+$console->init();
$console->run(); \ No newline at end of file
diff --git a/core/Console.php b/core/Console.php
index 410ffa5eb7..5dd628743b 100644
--- a/core/Console.php
+++ b/core/Console.php
@@ -14,10 +14,23 @@ use Symfony\Component\Console\Input\InputOption;
class Console
{
+ public function init()
+ {
+ $this->initPiwikHost();
+ $this->initConfig();
+ $this->initPlugins();
+ }
+
public function run()
{
- $console = new Application();
- $option = new InputOption('piwik-domain', null, InputOption::VALUE_OPTIONAL, 'Piwik URL (protocol and domain) eg. "http://piwik.example.org"');
+ $console = new Application();
+
+ $option = new InputOption('piwik-domain',
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'Piwik URL (protocol and domain) eg. "http://piwik.example.org"'
+ );
+
$console->getDefinition()->addOption($option);
$commands = $this->getAvailableCommands();
@@ -55,7 +68,7 @@ class Console
* should subscribe to this event and add commands to the incoming array.
*
* **Example**
- *
+ *
* public function addConsoleCommands(&$commands)
* {
* $commands[] = 'Piwik\Plugins\MyPlugin\Commands\MyCommand';
@@ -67,4 +80,29 @@ class Console
return $commands;
}
+
+ protected function initPiwikHost()
+ {
+ $piwikHostname = CronArchive::getParameterFromCli('piwik-domain', true);
+ $piwikHostname = UrlHelper::getHostFromUrl($piwikHostname);
+ Url::setHost($piwikHostname);
+ }
+
+ protected function initConfig()
+ {
+ $config = Config::getInstance();
+ try {
+ $config->checkLocalConfigFound();
+ return $config;
+ } catch (\Exception $e) {
+ die($e->getMessage() . "\n\n");
+ }
+ }
+
+ protected function initPlugins()
+ {
+ $pluginsToLoad = Config::getInstance()->Plugins['Plugins'];
+ $pluginsManager = Plugin\Manager::getInstance();
+ $pluginsManager->loadPlugins($pluginsToLoad);
+ }
}