Skip to content

Commit 16456c1

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-66100
2 parents c81519a + 7b47dc6 commit 16456c1

File tree

166 files changed

+8581
-992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+8581
-992
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Deploy\Collector;
7+
8+
use Magento\Deploy\Source\SourcePool;
9+
use Magento\Deploy\Package\Package;
10+
use Magento\Deploy\Package\PackageFactory;
11+
use Magento\Framework\View\Asset\PreProcessor\FileNameResolver;
12+
13+
/**
14+
* Class Collector
15+
*
16+
* Default implementation uses Source Pool object which provides collection of static files sources
17+
*
18+
* @see SourcePool
19+
*/
20+
class Collector implements CollectorInterface
21+
{
22+
/**
23+
* Source Pool object
24+
*
25+
* Provides the list of source objects
26+
*
27+
* @var SourcePool
28+
*/
29+
private $sourcePool;
30+
31+
/**
32+
* Resolver for deployed static file name
33+
*
34+
* A given file could be an alternative source for the real static file which needs to be deployed. In such case
35+
* resolver provides the final static file name
36+
*
37+
* @var FileNameResolver
38+
*/
39+
private $fileNameResolver;
40+
41+
/**
42+
* Factory class for Package object
43+
*
44+
* @see Package
45+
* @var PackageFactory
46+
*/
47+
private $packageFactory;
48+
49+
/**
50+
* Default values for package primary identifiers
51+
*
52+
* @var array
53+
*/
54+
private $packageDefaultValues = [
55+
'area' => Package::BASE_AREA,
56+
'theme' => Package::BASE_THEME,
57+
'locale' => Package::BASE_LOCALE
58+
];
59+
60+
/**
61+
* Collector constructor
62+
*
63+
* @param SourcePool $sourcePool
64+
* @param FileNameResolver $fileNameResolver
65+
* @param PackageFactory $packageFactory
66+
*/
67+
public function __construct(
68+
SourcePool $sourcePool,
69+
FileNameResolver $fileNameResolver,
70+
PackageFactory $packageFactory
71+
) {
72+
$this->sourcePool = $sourcePool;
73+
$this->fileNameResolver = $fileNameResolver;
74+
$this->packageFactory = $packageFactory;
75+
}
76+
77+
/**
78+
* @inheritdoc
79+
*/
80+
public function collect()
81+
{
82+
$packages = [];
83+
foreach ($this->sourcePool->getAll() as $source) {
84+
$files = $source->get();
85+
foreach ($files as $file) {
86+
$file->setDeployedFileName($this->fileNameResolver->resolve($file->getFileName()));
87+
$params = [
88+
'area' => $file->getArea(),
89+
'theme' => $file->getTheme(),
90+
'locale' => $file->getLocale(),
91+
'module' => $file->getModule(),
92+
'isVirtual' => (!$file->getLocale() || !$file->getTheme() || !$file->getArea())
93+
];
94+
foreach ($this->packageDefaultValues as $name => $value) {
95+
if (!isset($params[$name])) {
96+
$params[$name] = $value;
97+
}
98+
}
99+
$packagePath = "{$params['area']}/{$params['theme']}/{$params['locale']}";
100+
if (!isset($packages[$packagePath])) {
101+
$packages[$packagePath] = $this->packageFactory->create($params);
102+
}
103+
if ($file->getFilePath()) {
104+
$file->setPackage($packages[$packagePath]);
105+
}
106+
}
107+
}
108+
return $packages;
109+
}
110+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Deploy\Collector;
7+
8+
use Magento\Deploy\Package\Package;
9+
10+
/**
11+
* Interface CollectorInterface
12+
*
13+
* Collector returns packages with files which share same properties (e.g. area, theme, locale, etc)
14+
*
15+
* @api
16+
*/
17+
interface CollectorInterface
18+
{
19+
/**
20+
* Retrieve all static files from registered locations split to packages.
21+
* Unique package is identified for each combination of three key scope identifiers:
22+
* - area
23+
* - theme
24+
* - locale
25+
*
26+
* @return Package[]
27+
*/
28+
public function collect();
29+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Deploy\Config;
7+
8+
use Magento\Framework\View;
9+
use Magento\Framework\View\Design\Theme\ThemeProviderInterface;
10+
11+
/**
12+
* Class BundleConfig
13+
*
14+
* Use this to get configuration settings related to JavaScript built-in bundling
15+
*
16+
* @api
17+
*/
18+
class BundleConfig
19+
{
20+
/**
21+
* Namespace of the bundling configuration
22+
*/
23+
const VIEW_CONFIG_MODULE = 'Js_Bundle';
24+
25+
/**
26+
* Name of the bundle file size configuration setting
27+
*/
28+
const VIEW_CONFIG_BUNDLE_SIZE_NAME = 'bundle_size';
29+
30+
/**
31+
* Interface provides theme configuration settings
32+
*
33+
* @var View\ConfigInterface
34+
*/
35+
private $viewConfig;
36+
37+
/**
38+
* Theme provider interface
39+
*
40+
* Allows to retrieve theme by the them full path: "{area}/{vendor}/{theme}/{locale}"
41+
*
42+
* @var ThemeProviderInterface
43+
*/
44+
private $themeProvider;
45+
46+
/**
47+
* Configuration object cache
48+
*
49+
* @var \Magento\Framework\Config\View[]
50+
*/
51+
private $config = [];
52+
53+
/**
54+
* BundleConfig constructor
55+
*
56+
* @param View\ConfigInterface $viewConfig
57+
* @param ThemeProviderInterface $themeProvider
58+
*/
59+
public function __construct(
60+
View\ConfigInterface $viewConfig,
61+
ThemeProviderInterface $themeProvider
62+
) {
63+
$this->viewConfig = $viewConfig;
64+
$this->themeProvider = $themeProvider;
65+
}
66+
67+
/**
68+
* Max size of bundle files (in KB)
69+
*
70+
* @param string $area
71+
* @param string $theme
72+
* @return int
73+
*/
74+
public function getBundleFileMaxSize($area, $theme)
75+
{
76+
$size = $this->getConfig($area, $theme)->getVarValue(
77+
self::VIEW_CONFIG_MODULE,
78+
self::VIEW_CONFIG_BUNDLE_SIZE_NAME
79+
);
80+
$unit = preg_replace('/[^a-zA-Z]+/', '', $size);
81+
$unit = strtoupper($unit);
82+
switch ($unit) {
83+
case 'KB':
84+
return (int)$size;
85+
case 'MB':
86+
return (int)$size * 1024;
87+
default:
88+
return (int)($size / 1024);
89+
}
90+
}
91+
92+
/**
93+
* Get list of directories which must be excluded
94+
*
95+
* @param string $area
96+
* @param string $theme
97+
* @return array
98+
*/
99+
public function getExcludedDirectories($area, $theme)
100+
{
101+
return $this->getConfig($area, $theme)->getExcludedDir();
102+
}
103+
104+
/**
105+
* Get list of files which must be excluded from bundling
106+
*
107+
* @param string $area
108+
* @param string $theme
109+
* @return array
110+
*/
111+
public function getExcludedFiles($area, $theme)
112+
{
113+
return $this->getConfig($area, $theme)->getExcludedFiles();
114+
}
115+
116+
/**
117+
* Get View Configuration object related to the given area and theme
118+
*
119+
* @param string $area
120+
* @param string $theme
121+
* @return \Magento\Framework\Config\View
122+
*/
123+
private function getConfig($area, $theme)
124+
{
125+
$themePath = $area . '/' . $theme;
126+
if (!isset($this->config[$themePath])) {
127+
$this->config[$themePath] = $this->viewConfig->getViewConfig([
128+
'area' => $area,
129+
'themeModel' => $this->themeProvider->getThemeByFullPath($themePath)
130+
]);
131+
}
132+
return $this->config[$themePath];
133+
}
134+
}

app/code/Magento/Deploy/Console/Command/App/ApplicationDumpCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ApplicationDumpCommand extends Command
3636
private $configHash;
3737

3838
/**
39-
* ApplicationDumpCommand constructor.
39+
* ApplicationDumpCommand constructor
4040
*
4141
* @param Writer $writer
4242
* @param array $sources
@@ -54,7 +54,7 @@ public function __construct(
5454
}
5555

5656
/**
57-
* {@inheritdoc}
57+
* @inheritdoc
5858
*/
5959
protected function configure()
6060
{

app/code/Magento/Deploy/Console/Command/App/ConfigImport/Importer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,56 +8,56 @@
88
use Magento\Framework\App\DeploymentConfig\ImporterInterface;
99
use Magento\Framework\App\DeploymentConfig;
1010
use Magento\Framework\Exception\RuntimeException;
11-
use Psr\Log\LoggerInterface as Logger;
1211
use Magento\Deploy\Model\DeploymentConfig\Validator;
1312
use Magento\Deploy\Model\DeploymentConfig\ImporterPool;
1413
use Magento\Deploy\Model\DeploymentConfig\Hash;
1514
use Symfony\Component\Console\Input\InputInterface;
1615
use Symfony\Component\Console\Output\OutputInterface;
1716
use Magento\Deploy\Model\DeploymentConfig\ImporterFactory;
17+
use Psr\Log\LoggerInterface as Logger;
1818

1919
/**
2020
* Runs importing of config data from deployment configuration files.
2121
*/
2222
class Importer
2323
{
2424
/**
25-
* The configuration data validator.
25+
* The configuration data validator
2626
*
2727
* @var Validator
2828
*/
2929
private $configValidator;
3030

3131
/**
32-
* Pool of all deployment configuration importers.
32+
* Pool of all deployment configuration importers
3333
*
3434
* @var ImporterPool
3535
*/
3636
private $configImporterPool;
3737

3838
/**
39-
* Application deployment configuration.
39+
* Application deployment configuration
4040
*
4141
* @var DeploymentConfig
4242
*/
4343
private $deploymentConfig;
4444

4545
/**
46-
* Hash updater of config data.
46+
* Hash updater of config data
4747
*
4848
* @var Hash
4949
*/
5050
private $configHash;
5151

5252
/**
53-
* Factory for creation of importer instance.
53+
* Factory for creation of importer instance
5454
*
5555
* @var ImporterFactory
5656
*/
5757
private $importerFactory;
5858

5959
/**
60-
* Logger.
60+
* Logger
6161
*
6262
* @var Logger
6363
*/
@@ -98,7 +98,7 @@ public function __construct(
9898
}
9999

100100
/**
101-
* Runs importing of config data from deployment configuration files.
101+
* Runs importing of config data from deployment configuration files
102102
*
103103
* @param InputInterface $input The CLI input
104104
* @param OutputInterface $output The CLI output

app/code/Magento/Deploy/Console/Command/App/ConfigImportCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
use Magento\Deploy\Console\Command\App\ConfigImport\Importer;
1515

1616
/**
17-
* Runs the process of importing configuration data from shared source to appropriate application sources.
17+
* Runs the process of importing configuration data from shared source to appropriate application sources
1818
*
1919
* We have configuration files that are shared between environments, but some of the configurations are read only
2020
* from DB (e.g., themes, scopes and etc). This command is used to import such configurations from the file to
21-
* appropriate application sources.
21+
* appropriate application sources
2222
*/
2323
class ConfigImportCommand extends Command
2424
{
@@ -56,8 +56,7 @@ protected function configure()
5656
}
5757

5858
/**
59-
* Imports data from deployment configuration files to the DB.
60-
* {@inheritdoc}
59+
* Imports data from deployment configuration files to the DB. {@inheritdoc}
6160
*/
6261
protected function execute(InputInterface $input, OutputInterface $output)
6362
{

0 commit comments

Comments
 (0)