From a43a00aab23167969da2773a887f7f25b994ff6a Mon Sep 17 00:00:00 2001
From: Sergii Kovalenko <skovalenko@magento.com>
Date: Thu, 10 Nov 2016 18:55:12 +0200
Subject: [PATCH] MAGETWO-56989: Deployment process can't be executed on
 separate machine

-move deploy static command
---
 .../Magento/Cron/Model/Config/Reader/Db.php   |  2 +-
 app/code/Magento/Deploy/etc/di.xml            |  1 -
 .../Magento/Framework/Console/Cli.php         |  2 +-
 .../Command/DeployStaticContentCommand.php    | 20 +++++--------------
 .../src/Magento/Setup/Console/CommandList.php |  1 +
 5 files changed, 8 insertions(+), 18 deletions(-)
 rename {app/code/Magento/Deploy => setup/src/Magento/Setup}/Console/Command/DeployStaticContentCommand.php (96%)

diff --git a/app/code/Magento/Cron/Model/Config/Reader/Db.php b/app/code/Magento/Cron/Model/Config/Reader/Db.php
index 52e3a5aed54..9602775f181 100644
--- a/app/code/Magento/Cron/Model/Config/Reader/Db.php
+++ b/app/code/Magento/Cron/Model/Config/Reader/Db.php
@@ -39,8 +39,8 @@ class Db
         Config $config,
         \Magento\Cron\Model\Config\Converter\Db $converter
     ) {
-        $this->_converter = $converter;
         $this->config = $config;
+        $this->_converter = $converter;
     }
 
     /**
diff --git a/app/code/Magento/Deploy/etc/di.xml b/app/code/Magento/Deploy/etc/di.xml
index 2d7c805994f..f230238364a 100644
--- a/app/code/Magento/Deploy/etc/di.xml
+++ b/app/code/Magento/Deploy/etc/di.xml
@@ -23,7 +23,6 @@
     <type name="Magento\Framework\Console\CommandListInterface">
         <arguments>
             <argument name="commands" xsi:type="array">
-                <item name="staticContentDeployCommand" xsi:type="object">Magento\Deploy\Console\Command\DeployStaticContentCommand</item>
                 <item name="setModeCommand" xsi:type="object">Magento\Deploy\Console\Command\SetModeCommand</item>
                 <item name="showModeCommand" xsi:type="object">Magento\Deploy\Console\Command\ShowModeCommand</item>
                 <item name="dumpApplicationCommand" xsi:type="object">\Magento\Deploy\Console\Command\App\ApplicationDumpCommand</item>
diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php
index 8f534c4f67a..4da186fcf88 100644
--- a/lib/internal/Magento/Framework/Console/Cli.php
+++ b/lib/internal/Magento/Framework/Console/Cli.php
@@ -135,7 +135,7 @@ class Cli extends SymfonyApplication
                 $commands = array_merge($commands, $setupCommandList->getCommands());
             }
 
-            if (count($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->get('modules'))) {
+            if ($objectManager->get(\Magento\Framework\App\DeploymentConfig::class)->isAvailable()) {
                 /** @var \Magento\Framework\Console\CommandListInterface */
                 $commandList = $objectManager->create(\Magento\Framework\Console\CommandListInterface::class);
                 $commands = array_merge($commands, $commandList->getCommands());
diff --git a/app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php b/setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php
similarity index 96%
rename from app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php
rename to setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php
index 8a006c8154b..e7badbf908b 100644
--- a/app/code/Magento/Deploy/Console/Command/DeployStaticContentCommand.php
+++ b/setup/src/Magento/Setup/Console/Command/DeployStaticContentCommand.php
@@ -3,15 +3,15 @@
  * Copyright © 2016 Magento. All rights reserved.
  * See COPYING.txt for license details.
  */
-namespace Magento\Deploy\Console\Command;
+namespace Magento\Setup\Console\Command;
 
 use Magento\Framework\App\Utility\Files;
+use Magento\Setup\Model\ObjectManagerProvider;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Input\InputArgument;
-use Magento\Framework\App\ObjectManagerFactory;
 use Magento\Framework\ObjectManagerInterface;
 use Magento\Framework\Validator\Locale;
 use Magento\Framework\Exception\LocalizedException;
@@ -64,13 +64,6 @@ class DeployStaticContentCommand extends Command
      */
     private $validator;
 
-    /**
-     * Factory to get object manager
-     *
-     * @var ObjectManagerFactory
-     */
-    private $objectManagerFactory;
-
     /**
      * object manager to create various objects
      *
@@ -85,19 +78,16 @@ class DeployStaticContentCommand extends Command
     /**
      * Inject dependencies
      *
-     * @param ObjectManagerFactory $objectManagerFactory
      * @param Locale $validator
-     * @param ObjectManagerInterface $objectManager
+     * @param ObjectManagerProvider $objectManagerProvider
      * @throws \LogicException When the command name is empty
      */
     public function __construct(
-        ObjectManagerFactory $objectManagerFactory,
         Locale $validator,
-        ObjectManagerInterface $objectManager
+        ObjectManagerProvider $objectManagerProvider
     ) {
-        $this->objectManagerFactory = $objectManagerFactory;
         $this->validator = $validator;
-        $this->objectManager = $objectManager;
+        $this->objectManager = $objectManagerProvider->get();
 
         parent::__construct();
     }
diff --git a/setup/src/Magento/Setup/Console/CommandList.php b/setup/src/Magento/Setup/Console/CommandList.php
index 4bb5ac0181a..e025de44602 100644
--- a/setup/src/Magento/Setup/Console/CommandList.php
+++ b/setup/src/Magento/Setup/Console/CommandList.php
@@ -72,6 +72,7 @@ class CommandList
             \Magento\Setup\Console\Command\RollbackCommand::class,
             \Magento\Setup\Console\Command\UpgradeCommand::class,
             \Magento\Setup\Console\Command\UninstallCommand::class,
+            \Magento\Setup\Console\Command\DeployStaticContentCommand::class
         ];
     }
 
-- 
GitLab