Skip to content

Commit

Permalink
Merge pull request #1004 from magento-falcons/MAGETWO-67152
Browse files Browse the repository at this point in the history
[Falcons] Delivery of deployment improvements #2
  • Loading branch information
Yaroslav Onischenko authored Apr 7, 2017
2 parents 5640494 + 098eb09 commit e517984
Show file tree
Hide file tree
Showing 41 changed files with 1,134 additions and 604 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/Cron/SignUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\FlagManager;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;

Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/Cron/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
namespace Magento\Analytics\Cron;

use Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\CollectionTime;
use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\NotificationTime;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\Storage\WriterInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
namespace Magento\Analytics\Model\Connector;

use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Config\Model\Config;
use Magento\Framework\FlagManager;
use Magento\Framework\HTTP\ZendClient;
use Magento\Store\Model\Store;
use Psr\Log\LoggerInterface;
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Analytics/Model/FileInfoManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Analytics\Model;

use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\FlagManager;

/**
* Manage saving and loading FileInfo object.
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Analytics/Model/NotificationTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Analytics\Model;

use Magento\Framework\FlagManager;

/**
* Class NotificationTime
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/
namespace Magento\Analytics\Model\Plugin;

use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\Storage\WriterInterface;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Config\App\Config\Type\System;
use Magento\Framework\FlagManager;

/**
* Provider of subscription status.
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/Test/Unit/Cron/SignUpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Magento\Analytics\Cron\SignUp;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\FlagManager;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/Test/Unit/Cron/UpdateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

use Magento\Analytics\Cron\Update;
use Magento\Analytics\Model\Connector;
use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Framework\App\Config\ReinitableConfigInterface;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;

/**
* Class Update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\CollectionTime;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\NotificationTime;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Connector\Http\ClientInterface;
use Magento\Analytics\Model\Connector\UpdateCommand;
use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Config\Model\Config;
use Magento\Framework\FlagManager;
use Magento\Framework\HTTP\ZendClient;
use Psr\Log\LoggerInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Magento\Analytics\Model\FileInfo;
use Magento\Analytics\Model\FileInfoFactory;
use Magento\Analytics\Model\FileInfoManager;
use Magento\Analytics\Model\FlagManager;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Magento\Analytics\Test\Unit\Model;

use Magento\Analytics\Model\FlagManager;
use Magento\Framework\FlagManager;
use Magento\Analytics\Model\NotificationTime;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
*/
namespace Magento\Analytics\Test\Unit\Model\Plugin;

use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\Plugin\BaseUrlConfigPlugin;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Config\Model\Config\Backend\Baseurl;
use Magento\Framework\FlagManager;
use Magento\Framework\App\Config\Storage\WriterInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Store\Model\Store;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

use Magento\Analytics\Model\AnalyticsToken;
use Magento\Analytics\Model\Config\Backend\Enabled\SubscriptionHandler;
use Magento\Analytics\Model\FlagManager;
use Magento\Analytics\Model\SubscriptionStatusProvider;
use Magento\Config\App\Config\Type\System;
use Magento\Framework\FlagManager;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Config\App\Config\Source;

use Magento\Framework\App\Config\ConfigSourceInterface;
use Magento\Framework\DataObjectFactory;
use Magento\Framework\FlagManager;

/**
* The source with previously imported configuration.
*/
class InitialSnapshotConfigSource implements ConfigSourceInterface
{
/**
* The factory of Flag instances.
*
* @var FlagManager
*/
private $flagManager;

/**
* The factory of DataObject instances.
*
* @var DataObjectFactory
*/
private $dataObjectFactory;

/**
* @param FlagManager $flagManager The factory of Flag instances
* @param DataObjectFactory $dataObjectFactory The factory of DataObject instances
*/
public function __construct(FlagManager $flagManager, DataObjectFactory $dataObjectFactory)
{
$this->flagManager = $flagManager;
$this->dataObjectFactory = $dataObjectFactory;
}

/**
* Retrieves previously imported configuration.
* Snapshots are stored in flags.
*
* {@inheritdoc}
*/
public function get($path = '')
{
$flagData = (array)($this->flagManager->getFlagData('system_config_snapshot') ?: []);

$data = $this->dataObjectFactory->create(
['data' => $flagData]
);

return $data->getData($path) ?: [];
}
}
16 changes: 13 additions & 3 deletions app/code/Magento/Config/App/Config/Type/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ class System implements ConfigTypeInterface
*/
private $serializer;

/**
* The type of config.
*
* @var string
*/
private $configType;

/**
* @param \Magento\Framework\App\Config\ConfigSourceInterface $source
* @param \Magento\Framework\App\Config\Spi\PostProcessorInterface $postProcessor
Expand All @@ -65,6 +72,7 @@ class System implements ConfigTypeInterface
* @param \Magento\Framework\Serialize\SerializerInterface $serializer
* @param \Magento\Framework\App\Config\Spi\PreProcessorInterface $preProcessor
* @param int $cachingNestedLevel
* @param string $configType
*/
public function __construct(
\Magento\Framework\App\Config\ConfigSourceInterface $source,
Expand All @@ -73,7 +81,8 @@ public function __construct(
\Magento\Framework\Cache\FrontendInterface $cache,
\Magento\Framework\Serialize\SerializerInterface $serializer,
\Magento\Framework\App\Config\Spi\PreProcessorInterface $preProcessor,
$cachingNestedLevel = 1
$cachingNestedLevel = 1,
$configType = self::CONFIG_TYPE
) {
$this->source = $source;
$this->postProcessor = $postProcessor;
Expand All @@ -82,6 +91,7 @@ public function __construct(
$this->cachingNestedLevel = $cachingNestedLevel;
$this->fallback = $fallback;
$this->serializer = $serializer;
$this->configType = $configType;
}

/**
Expand All @@ -93,7 +103,7 @@ public function get($path = '')
$path = '';
}
if (!$this->data) {
$data = $this->cache->load(self::CONFIG_TYPE);
$data = $this->cache->load($this->configType);
if (!$data) {
$data = $this->preProcessor->process($this->source->get());
$this->data = new DataObject($data);
Expand All @@ -104,7 +114,7 @@ public function get($path = '')
$this->data = new DataObject($data);
$this->cache->save(
$this->serializer->serialize($this->data->getData()),
self::CONFIG_TYPE,
$this->configType,
[self::CACHE_TAG]
);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Config\Console\Command\ConfigSet;

use Magento\Framework\App\Area;
use Magento\Framework\App\State;
use Magento\Framework\Config\ScopeInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\RuntimeException;

/**
* Processor facade for config:set command with emulated adminhtml area.
*/
class EmulatedProcessorFacade
{
/**
* The factory for processor facade.
*
* @var ProcessorFacadeFactory
*/
private $processorFacadeFactory;

/**
* The application scope manager.
*
* @var ScopeInterface
*/
private $scope;

/**
* The application state manager.
*
* @var State
*/
private $state;

/**
* @param ScopeInterface $scope The application scope manager
* @param State $state The application state manager
* @param ProcessorFacadeFactory $processorFacadeFactory The factory for processor facade
*/
public function __construct(
ScopeInterface $scope,
State $state,
ProcessorFacadeFactory $processorFacadeFactory
) {
$this->scope = $scope;
$this->state = $state;
$this->processorFacadeFactory = $processorFacadeFactory;
}

/**
* Processes config:set command.
*
* @param string $path The configuration path in format group/section/field_name
* @param string $value The configuration value
* @param string $scope The configuration scope (default, website, or store)
* @param string $scopeCode The scope code
* @param boolean $lock The lock flag
* @return string Processor response message
* @throws RuntimeException If exception was catch
*/
public function process($path, $value, $scope, $scopeCode, $lock)
{
$currentScope = $this->scope->getCurrentScope();

try {
// Emulating adminhtml scope to be able to read configs.
return $this->state->emulateAreaCode(Area::AREA_ADMINHTML, function () use (
$path,
$value,
$scope,
$scopeCode,
$lock
) {
$this->scope->setCurrentScope(Area::AREA_ADMINHTML);

return $this->processorFacadeFactory->create()->process(
$path,
$value,
$scope,
$scopeCode,
$lock
);
});
} catch (LocalizedException $exception) {
throw new RuntimeException(__('%1', $exception->getMessage()), $exception);
} finally {
$this->scope->setCurrentScope($currentScope);
}
}
}
Loading

0 comments on commit e517984

Please sign in to comment.