]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Enhance requirements in InstallCommand
authorNicolas Lœuillet <nicolas.loeuillet@smile.fr>
Tue, 23 Feb 2016 15:41:38 +0000 (16:41 +0100)
committerNicolas Lœuillet <nicolas.loeuillet@smile.fr>
Tue, 23 Feb 2016 15:41:38 +0000 (16:41 +0100)
src/Wallabag/CoreBundle/Command/InstallCommand.php

index 84bd51fa220060a65088ebbf7a699c493cc8a9a7..f1111cce650c24ac800c724abf3ed33f4bdcbc67 100644 (file)
@@ -26,6 +26,14 @@ class InstallCommand extends ContainerAwareCommand
      */
     protected $defaultOutput;
 
+    /**
+     * @var array
+     */
+    protected $requirements = [
+        'pcre',
+        'DOM',
+    ];
+
     protected function configure()
     {
         $this
@@ -65,27 +73,18 @@ class InstallCommand extends ContainerAwareCommand
 
         $fulfilled = true;
 
-        $label = '<comment>PCRE</comment>';
-        if (extension_loaded('pcre')) {
-            $status = '<info>OK!</info>';
-            $help = '';
-        } else {
-            $fulfilled = false;
-            $status = '<error>ERROR!</error>';
-            $help = 'You should enabled PCRE extension';
-        }
-        $rows[] = array($label, $status, $help);
-
-        $label = '<comment>DOM</comment>';
-        if (extension_loaded('DOM')) {
-            $status = '<info>OK!</info>';
-            $help = '';
-        } else {
-            $fulfilled = false;
-            $status = '<error>ERROR!</error>';
-            $help = 'You should enabled DOM extension';
+        foreach ($this->requirements as $requirement) {
+            $label = '<comment>'.strtoupper($requirement).'</comment>';
+            if (extension_loaded($requirement)) {
+                $status = '<info>OK!</info>';
+                $help = '';
+            } else {
+                $fulfilled = false;
+                $status = '<error>ERROR!</error>';
+                $help = 'You should enabled '.$requirement.' extension';
+            }
+            $rows[] = array($label, $status, $help);
         }
-        $rows[] = array($label, $status, $help);
 
         $table = new Table($this->defaultOutput);
         $table