Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / src / Command / ServerCommand.php
index 1d7fcb5e2e92a2ca0c72f008de2a32bf255c8711..e306ceecad63b0db5d82a4f086f96a895b008ac4 100644 (file)
@@ -15,6 +15,7 @@ use Symfony\Component\Process\PhpExecutableFinder;
 use Symfony\Component\Console\Command\Command;
 use Drupal\Console\Core\Command\Shared\CommandTrait;
 use Drupal\Console\Core\Style\DrupalStyle;
+use \Drupal\Console\Core\Utils\ConfigurationManager;
 
 /**
  * Class ServerCommand
@@ -25,8 +26,14 @@ class ServerCommand extends Command
 {
     use CommandTrait;
 
+    /**
+     * @var string
+     */
     protected $appRoot;
 
+    /**
+     * @var ConfigurationManager
+     */
     protected $configurationManager;
 
     /**
@@ -65,13 +72,12 @@ class ServerCommand extends Command
     protected function execute(InputInterface $input, OutputInterface $output)
     {
         $io = new DrupalStyle($input, $output);
-        $learning = $input->hasOption('learning')?$input->getOption('learning'):false;
         $address = $this->validatePort($input->getArgument('address'));
 
         $finder = new PhpExecutableFinder();
         if (false === $binary = $finder->find()) {
             $io->error($this->trans('commands.server.errors.binary'));
-            return;
+            return 1;
         }
 
         $router = $this->getRouterPath();
@@ -90,7 +96,7 @@ class ServerCommand extends Command
         $io->commentBlock(
             sprintf(
                 $this->trans('commands.server.messages.listening'),
-                $address
+                'http://'.$address
             )
         );
 
@@ -99,7 +105,10 @@ class ServerCommand extends Command
 
         if (!$process->isSuccessful()) {
             $io->error($process->getErrorOutput());
+            return 1;
         }
+
+        return 0;
     }
 
     /**
@@ -107,22 +116,26 @@ class ServerCommand extends Command
      */
     private function getRouterPath()
     {
-        $router = sprintf(
-            '%s/.console/router.php',
-            $this->configurationManager->getHomeDirectory()
-        );
-
-        if (file_exists($router)) {
-            return $router;
-        }
-
-        $router = sprintf(
-            '%s/config/dist/router.php',
-            $this->configurationManager->getApplicationDirectory()
-        );
+        $routerPath = [
+            sprintf(
+                '%s/.console/router.php',
+                $this->configurationManager->getHomeDirectory()
+            ),
+            sprintf(
+                '%s/console/router.php',
+                $this->configurationManager->getApplicationDirectory()
+            ),
+            sprintf(
+                '%s/%s/config/dist/router.php',
+                $this->configurationManager->getApplicationDirectory(),
+                DRUPAL_CONSOLE_CORE
+            )
+        ];
 
-        if (file_exists($router)) {
-            return $router;
+        foreach ($routerPath as $router) {
+            if (file_exists($router)) {
+                return $router;
+            }
         }
 
         return null;