Skip to content

Commit 2424d1f

Browse files
author
Igor Miniailo
committed
Merge branch 'PR4' into product-video-PR4
2 parents 66cf5b7 + aea41d7 commit 2424d1f

File tree

8 files changed

+102
-25
lines changed

8 files changed

+102
-25
lines changed

app/code/Magento/Catalog/Model/Product/Image.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,10 +332,10 @@ public function setSize($size)
332332
list($width, $height) = explode('x', strtolower($size), 2);
333333
foreach (['width', 'height'] as $wh) {
334334
${$wh}
335-
= (int)${$wh};
335+
= (int)${$wh};
336336
if (empty(${$wh})) {
337337
${$wh}
338-
= null;
338+
= null;
339339
}
340340
}
341341

@@ -353,7 +353,8 @@ protected function _checkMemory($file = null)
353353
{
354354
return $this->_getMemoryLimit() > $this->_getMemoryUsage() + $this->_getNeedMemoryForFile(
355355
$file
356-
) || $this->_getMemoryLimit() == -1;
356+
)
357+
|| $this->_getMemoryLimit() == -1;
357358
}
358359

359360
/**
@@ -710,8 +711,8 @@ public function getUrl()
710711
);
711712
} else {
712713
$url = $this->_storeManager->getStore()->getBaseUrl(
713-
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
714-
) . $this->_newFile;
714+
\Magento\Framework\UrlInterface::URL_TYPE_MEDIA
715+
) . $this->_newFile;
715716
}
716717

717718
return $url;
@@ -939,14 +940,17 @@ protected function _fileExists($filename)
939940
*/
940941
public function getResizedImageInfo()
941942
{
943+
$fileInfo = null;
942944
if ($this->_newFile === true) {
943-
$fileInfo = getimagesize(
944-
$this->_assetRepo->createAsset(
945-
"Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg"
946-
)->getSourceFile()
945+
$asset = $this->_assetRepo->createAsset(
946+
"Magento_Catalog::images/product/placeholder/{$this->getDestinationSubdir()}.jpg"
947947
);
948+
$img = $asset->getSourceFile();
949+
$fileInfo = getimagesize($img);
948950
} else {
949-
$fileInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($this->_newFile));
951+
if ($this->_mediaDirectory->isFile($this->_mediaDirectory->getAbsolutePath($this->_newFile))) {
952+
$fileInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($this->_newFile));
953+
}
950954
}
951955
return $fileInfo;
952956
}

app/code/Magento/ProductVideo/view/frontend/web/js/fotorama-add-video-events.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,13 @@ define([
549549
waitForFroogaloop = setInterval($.proxy(function () {
550550
if (window.Froogaloop) {
551551
clearInterval(waitForFroogaloop);
552+
fotorama.requestFullScreen();
552553
$(this.element).data('fotorama').activeFrame.$stageFrame[0].click();
554+
$('.fotorama__fullscreen-icon').css({
555+
opacity: '1',
556+
visibility: 'visible',
557+
display: 'block'
558+
});
553559
this.Base = false;
554560
}
555561
}, this), 50);

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Fixture/Product/MediaGallery.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public function __construct(array $params, $data = [])
4747
*
4848
* @param string $filename
4949
* @return void
50-
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
5150
*/
5251
protected function createTestImage($filename)
5352
{
@@ -58,8 +57,6 @@ protected function createTestImage($filename)
5857

5958
// Create a color (this first call to imageColorAllocate
6059
// also automatically sets the image background color)
61-
$colorRed = imageColorAllocate($image, 255, 0, 0);
62-
// Create another color
6360
$colorYellow = imageColorAllocate($image, 255, 255, 0);
6461

6562
// Draw a rectangle

dev/tests/functional/tests/app/Magento/ProductVideo/Test/Repository/ConfigData.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,33 @@
1111
<field name="catalog/product_video/youtube_api_key" xsi:type="array">
1212
<item name="scope" xsi:type="string">default</item>
1313
<item name="scope_id" xsi:type="number">0</item>
14-
<item name="label" xsi:type="string"/>
14+
<item name="label" xsi:type="string">Yes</item>
1515
<item name="value" xsi:type="string">AIzaSyDwqDWuw1lra-LnpJL2Mr02DYuFmkuRSns</item>
1616
</field>
1717
</dataset>
1818
<dataset name="youtube_api_key_rollback">
1919
<field name="catalog/product_video/youtube_api_key" xsi:type="array">
2020
<item name="scope" xsi:type="string">default</item>
2121
<item name="scope_id" xsi:type="number">0</item>
22-
<item name="label" xsi:type="string"/>
22+
<item name="label" xsi:type="string">Yes</item>
2323
<item name="value" xsi:type="string"/>
2424
</field>
2525
</dataset>
26+
<dataset name="play_if_base">
27+
<field name="catalog/product_video/play_if_base" xsi:type="array">
28+
<item name="scope" xsi:type="string">default</item>
29+
<item name="scope_id" xsi:type="number">0</item>
30+
<item name="label" xsi:type="string">Yes</item>
31+
<item name="value" xsi:type="string">0</item>
32+
</field>
33+
</dataset>
34+
<dataset name="play_if_base_rollback">
35+
<field name="catalog/product_video/play_if_base" xsi:type="array">
36+
<item name="scope" xsi:type="string">default</item>
37+
<item name="scope_id" xsi:type="number">0</item>
38+
<item name="label" xsi:type="string">Yes</item>
39+
<item name="value" xsi:type="string">1</item>
40+
</field>
41+
</dataset>
2642
</repository>
2743
</config>

dev/tests/functional/tests/app/Magento/ProductVideo/Test/TestCase/UpdateSimpleProductEntityTest.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<data name="product/data/media_gallery/images/0/video_url" xsi:type="string">https://youtu.be/WMp2PvU2qi8</data>
3535
<data name="product/data/media_gallery/images/0/video_title" xsi:type="string">Foo Test 1</data>
3636
<data name="product/data/media_gallery/images/0/video_description" xsi:type="string">This is a test "Foo Test 1"</data>
37-
<data name="configData" xsi:type="string">youtube_api_key</data>
37+
<data name="configData" xsi:type="string">youtube_api_key,play_if_base</data>
3838
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoCategoryView" />
3939
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoProductView" />
4040
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
@@ -46,6 +46,7 @@
4646
<data name="product/data/media_gallery/images/0/video_url" xsi:type="string">https://vimeo.com/21776334</data>
4747
<data name="product/data/media_gallery/images/0/video_title" xsi:type="string">Foo Test 2</data>
4848
<data name="product/data/media_gallery/images/0/video_description" xsi:type="string">This is a test "Foo Test 2"</data>
49+
<data name="configData" xsi:type="string">play_if_base</data>
4950
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoCategoryView" />
5051
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoProductView" />
5152
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
@@ -56,7 +57,7 @@
5657
<data name="product/data/sku" xsi:type="string">sku_simple_product_with_video_%isolation%</data>
5758
<data name="product/data/media_gallery/images/0/video_url" xsi:type="string">https://youtu.be/WMp2PvU2qi8</data>
5859
<data name="product/data/media_gallery/images/0/video_title" xsi:type="string">Foo Test 1</data>
59-
<data name="configData" xsi:type="string">youtube_api_key</data>
60+
<data name="configData" xsi:type="string">youtube_api_key,play_if_base</data>
6061
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoCategoryView" />
6162
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoProductView" />
6263
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
@@ -66,6 +67,7 @@
6667
<data name="product/data/sku" xsi:type="string">simple_product_with_category_%isolation%</data>
6768
<data name="product/data/media_gallery/images/0/video_url" xsi:type="string">https://vimeo.com/21776334</data>
6869
<data name="product/data/media_gallery/images/0/video_title" xsi:type="string">Foo Test 2</data>
70+
<data name="configData" xsi:type="string">play_if_base</data>
6971
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoCategoryView" />
7072
<constraint name="Magento\ProductVideo\Test\Constraint\AssertVideoProductView" />
7173
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
@@ -75,14 +77,15 @@
7577
<data name="initialProduct/dataset" xsi:type="string">product_with_video_youtube</data>
7678
<data name="product/data/sku" xsi:type="string">sku_simple_product_with_video_%isolation%</data>
7779
<data name="product/data/media_gallery/images/0/video_url" xsi:type="string">https://youtu.be/bpOSxM0rNPM</data>
78-
<data name="configData" xsi:type="string">youtube_api_key</data>
80+
<data name="configData" xsi:type="string">youtube_api_key,play_if_base</data>
7981
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
8082
</variation>
8183
<variation name="UpdateVideoInPCFTestVariation2">
8284
<data name="description" xsi:type="string">Edit vimeo URL</data>
8385
<data name="initialProduct/dataset" xsi:type="string">product_with_video_youtube</data>
8486
<data name="product/data/sku" xsi:type="string">sku_simple_product_with_video_%isolation%</data>
8587
<data name="productVideo/data/media_gallery/images/0/video_url" xsi:type="string">https://vimeo.com/16342611</data>
88+
<data name="configData" xsi:type="string">play_if_base</data>
8689
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
8790
</variation>
8891
<variation name="UpdateVideoInPCFTestVariation3">
@@ -91,6 +94,7 @@
9194
<data name="product/data/sku" xsi:type="string">sku_simple_product_with_video_%isolation%</data>
9295
<data name="productVideo/data/media_gallery/images/0/video_title" xsi:type="string">Edit Test</data>
9396
<data name="productVideo/data/media_gallery/images/0/video_description" xsi:type="string">This is an edit test</data>
97+
<data name="configData" xsi:type="string">play_if_base</data>
9498
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
9599
</variation>
96100
<variation name="UpdateVideoInPCFTestVariation4">
@@ -100,7 +104,7 @@
100104
<data name="productVideo/data/media_gallery/images/0/video_url" xsi:type="string">https://youtu.be/bpOSxM0rNPM</data>
101105
<data name="productVideo/data/media_gallery/images/0/video_title" xsi:type="string">Edit Test</data>
102106
<data name="productVideo/data/media_gallery/images/0/video_description" xsi:type="string">This is an edit test</data>
103-
<data name="configData" xsi:type="string">youtube_api_key</data>
107+
<data name="configData" xsi:type="string">youtube_api_key,play_if_base</data>
104108
<constraint name="Magento\Catalog\Test\Constraint\AssertProductForm" />
105109
</variation>
106110
<variation name="GetVideoInfoTestVariation1">
@@ -109,7 +113,7 @@
109113
<data name="product/data/sku" xsi:type="string">simple_product_with_category_%isolation%</data>
110114
<data name="product/data/media_gallery/images/0/video_url" xsi:type="string">https://youtu.be/WMp2PvU2qi8</data>
111115
<data name="video/video_title" xsi:type="string">Foo Fighters - Congregation</data>
112-
<data name="configData" xsi:type="string">youtube_api_key</data>
116+
<data name="configData" xsi:type="string">youtube_api_key,play_if_base</data>
113117
<constraint name="Magento\ProductVideo\Test\Constraint\AssertGetVideoInfoDataIsCorrect" />
114118
</variation>
115119
<variation name="GetVideoInfoTestVariation2">
@@ -118,6 +122,7 @@
118122
<data name="product/data/sku" xsi:type="string">simple_product_with_category_%isolation%</data>
119123
<data name="product/data/media_gallery/images/0/video_url" xsi:type="string">https://vimeo.com/21776334</data>
120124
<data name="video/video_title" xsi:type="string">Foo Fighters - "Walk" - Official Music Video (HD)</data>
125+
<data name="configData" xsi:type="string">play_if_base</data>
121126
<constraint name="Magento\ProductVideo\Test\Constraint\AssertGetVideoInfoDataIsCorrect" />
122127
</variation>
123128
</testCase>

dev/tests/integration/testsuite/Magento/Catalog/controllers/_files/products.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
use Magento\Framework\App\Filesystem\DirectoryList;
1010

1111
$obectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
12+
13+
$obectManager->get(
14+
'Magento\Framework\View\DesignInterface'
15+
)->setArea(
16+
'frontend'
17+
)->setDefaultDesignTheme();
18+
1219
/** @var \Magento\Catalog\Model\Product\Media\Config $config */
1320
$config = $obectManager->get('Magento\Catalog\Model\Product\Media\Config');
1421
/** @var \Magento\Framework\Filesystem\Directory\WriteInterface $mediaDirectory */

dev/tests/integration/testsuite/Magento/Theme/Model/View/DesignTest.php

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,31 @@ public function getFilenameDataProvider()
174174
public function testGetViewConfig()
175175
{
176176
$this->_emulateFixtureTheme();
177-
$config = $this->_viewConfig->getViewConfig();
178-
$this->assertInstanceOf('Magento\Framework\Config\View', $config);
179-
$this->assertEquals(['var1' => 'value1', 'var2' => 'value2'], $config->getVars('Namespace_Module'));
177+
/** @var $theme \Magento\Framework\View\Design\ThemeInterface */
178+
$theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
179+
'Magento\Framework\View\DesignInterface'
180+
)->getDesignTheme();
181+
$customConfigFile = $theme->getCustomization()->getCustomViewConfigPath();
182+
/** @var $filesystem \Magento\Framework\Filesystem */
183+
$filesystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
184+
->create('Magento\Framework\Filesystem');
185+
$directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
186+
$relativePath = $directory->getRelativePath($customConfigFile);
187+
try {
188+
$directory->writeFile(
189+
$relativePath,
190+
'<?xml version="1.0" encoding="UTF-8"?>
191+
<view><vars module="Namespace_Module"><var name="var">var value</var></vars></view>'
192+
);
193+
194+
$config = $this->_viewConfig->getViewConfig();
195+
$this->assertInstanceOf('Magento\Framework\Config\View', $config);
196+
$this->assertEquals('var value', $config->getVarValue('Namespace_Module', 'var'));
197+
} catch (\Exception $e) {
198+
$directory->delete($relativePath);
199+
throw $e;
200+
}
201+
$directory->delete($relativePath);
180202
}
181203

182204
/**

lib/internal/Magento/Framework/Config/FileResolver.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,33 @@ class FileResolver implements \Magento\Framework\Config\FileResolverInterface
4343
protected $area;
4444

4545
/**
46-
* @param \Magento\Framework\Module\Dir\Reader $moduleReader
46+
* Root directory
47+
*
48+
* @var ReadInterface
49+
*/
50+
protected $rootDirectory;
51+
52+
/**
53+
* @param Reader $moduleReader
4754
* @param FileIteratorFactory $iteratorFactory
4855
* @param DesignInterface $designInterface
4956
* @param DirectoryList $directoryList
57+
* @param Filesystem $filesystem
5058
*/
5159
public function __construct(
5260
Reader $moduleReader,
5361
FileIteratorFactory $iteratorFactory,
5462
DesignInterface $designInterface,
55-
DirectoryList $directoryList
63+
DirectoryList $directoryList,
64+
Filesystem $filesystem
5665
) {
5766
$this->directoryList = $directoryList;
5867
$this->iteratorFactory = $iteratorFactory;
5968
$this->moduleReader = $moduleReader;
6069
$this->currentTheme = $designInterface->getDesignTheme();
6170
$this->themePath = $designInterface->getThemePath($this->currentTheme);
6271
$this->area = $designInterface->getArea();
72+
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
6373
}
6474

6575
/**
@@ -70,6 +80,16 @@ public function get($filename, $scope)
7080
switch ($scope) {
7181
case 'global':
7282
$iterator = $this->moduleReader->getConfigurationFiles($filename)->toArray();
83+
84+
$themeConfigFile = $this->currentTheme->getCustomization()->getCustomViewConfigPath();
85+
if ($themeConfigFile
86+
&& $this->rootDirectory->isExist($this->rootDirectory->getRelativePath($themeConfigFile))
87+
) {
88+
$iterator[$this->rootDirectory->getRelativePath($themeConfigFile)] = $this->rootDirectory->readFile(
89+
$this->rootDirectory->getRelativePath($themeConfigFile)
90+
);
91+
}
92+
7393
$designPath =
7494
$this->directoryList->getPath(DirectoryList::APP)
7595
. '/design/'

0 commit comments

Comments
 (0)