Skip to content

Commit d8a4d0e

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into api-coverate
2 parents a26921b + 86d67e4 commit d8a4d0e

File tree

185 files changed

+8931
-1053
lines changed

Some content is hidden

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

185 files changed

+8931
-1053
lines changed

app/code/Magento/Backend/Model/Url.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Backend\Model;
77

8+
use Magento\Framework\Serialize\Serializer\Json;
89
use Magento\Framework\Url\HostChecker;
910
use Magento\Framework\App\ObjectManager;
1011

@@ -101,6 +102,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn
101102
* @param \Magento\Framework\Data\Form\FormKey $formKey
102103
* @param array $data
103104
* @param HostChecker|null $hostChecker
105+
* @param Json $serializer
104106
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
105107
*/
106108
public function __construct(
@@ -123,7 +125,8 @@ public function __construct(
123125
\Magento\Store\Model\StoreFactory $storeFactory,
124126
\Magento\Framework\Data\Form\FormKey $formKey,
125127
array $data = [],
126-
HostChecker $hostChecker = null
128+
HostChecker $hostChecker = null,
129+
Json $serializer = null
127130
) {
128131
$this->_encryptor = $encryptor;
129132
$hostChecker = $hostChecker ?: ObjectManager::getInstance()->get(HostChecker::class);
@@ -140,7 +143,8 @@ public function __construct(
140143
$routeParamsPreprocessor,
141144
$scopeType,
142145
$data,
143-
$hostChecker
146+
$hostChecker,
147+
$serializer
144148
);
145149
$this->_backendHelper = $backendHelper;
146150
$this->_menuConfig = $menuConfig;

app/code/Magento/Backend/Test/Unit/Model/UrlTest.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Backend\Test\Unit\Model;
77

8+
use Magento\Framework\Serialize\Serializer\Json;
89
use Magento\Framework\Url\HostChecker;
910

1011
/**
@@ -68,6 +69,11 @@ class UrlTest extends \PHPUnit_Framework_TestCase
6869
*/
6970
protected $_encryptor;
7071

72+
/**
73+
* @var Json|\PHPUnit_Framework_MockObject_MockObject
74+
*/
75+
private $serializerMock;
76+
7177
/**
7278
* @return void
7379
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -151,6 +157,20 @@ protected function setUp()
151157
->willReturn($routeParamsResolver);
152158
/** @var HostChecker|\PHPUnit_Framework_MockObject_MockObject $hostCheckerMock */
153159
$hostCheckerMock = $this->getMock(HostChecker::class, [], [], '', false);
160+
$this->serializerMock = $this->getMockBuilder(Json::class)
161+
->setMethods(['serialize'])
162+
->disableOriginalConstructor()
163+
->getMock();
164+
165+
$this->serializerMock->expects($this->any())
166+
->method('serialize')
167+
->will(
168+
$this->returnCallback(
169+
function ($value) {
170+
return json_encode($value);
171+
}
172+
)
173+
);
154174
$this->_model = $objectManager->getObject(
155175
\Magento\Backend\Model\Url::class,
156176
[
@@ -161,7 +181,8 @@ protected function setUp()
161181
'authSession' => $this->_authSessionMock,
162182
'encryptor' => $this->_encryptor,
163183
'routeParamsResolverFactory' => $this->routeParamsResolverFactoryMock,
164-
'hostChecker' => $hostCheckerMock
184+
'hostChecker' => $hostCheckerMock,
185+
'serializer' => $this->serializerMock
165186
]
166187
);
167188
$this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false);

app/code/Magento/Catalog/Test/Unit/Block/Rss/CategoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ protected function setUp()
9595
$this->request->expects($this->at(0))->method('getParam')->with('cid')->will($this->returnValue(1));
9696
$this->request->expects($this->at(1))->method('getParam')->with('store_id')->will($this->returnValue(null));
9797

98-
$this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class);
98+
$this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class, [], [], '', false);
9999
$this->catalogHelper = $this->getMock(\Magento\Catalog\Helper\Data::class, [], [], '', false);
100100
$this->categoryFactory = $this->getMockBuilder(\Magento\Catalog\Model\CategoryFactory::class)
101101
->setMethods(['create'])

app/code/Magento/CatalogWidget/Test/Unit/Block/Product/ProductsListTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function setUp()
9393
->setMethods(['getVisibleInCatalogIds'])
9494
->disableOriginalConstructor()
9595
->getMock();
96-
$this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class);
96+
$this->httpContext = $this->getMock(\Magento\Framework\App\Http\Context::class, [], [], '', false);
9797
$this->builder = $this->getMock(\Magento\Rule\Model\Condition\Sql\Builder::class, [], [], '', false);
9898
$this->rule = $this->getMock(\Magento\CatalogWidget\Model\Rule::class, [], [], '', false);
9999
$this->serializer = $this->getMock(\Magento\Framework\Serialize\Serializer\Json::class, [], [], '', false);
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
{

0 commit comments

Comments
 (0)