Skip to content

Commit 4f13fae

Browse files
author
Oleksandr Karpenko
committed
Merge remote-tracking branch 'origin/MAGETWO-50767' into BUGS
2 parents 49c53d3 + cf7fe97 commit 4f13fae

File tree

8 files changed

+88
-15
lines changed

8 files changed

+88
-15
lines changed

app/code/Magento/Catalog/etc/config.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,12 @@
5757
</allowed_resources>
5858
</media_storage_configuration>
5959
</system>
60+
<design>
61+
<watermark>
62+
<image_position>stretch</image_position>
63+
<small_image_position>stretch</small_image_position>
64+
<thumbnail_position>stretch</thumbnail_position>
65+
</watermark>
66+
</design>
6067
</default>
6168
</config>

app/code/Magento/Catalog/etc/di.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@
630630
<item name="watermark_image_position" xsi:type="array">
631631
<item name="path" xsi:type="string">design/watermark/image_position</item>
632632
<item name="fieldset" xsi:type="string">other_settings/watermark/image</item>
633-
<item name="default" xsi:type="string">stretch</item>
633+
634634
</item>
635635
<item name="watermark_small_image_size" xsi:type="array">
636636
<item name="path" xsi:type="string">design/watermark/small_image_size</item>
@@ -658,7 +658,6 @@
658658
<item name="watermark_small_image_position" xsi:type="array">
659659
<item name="path" xsi:type="string">design/watermark/small_image_position</item>
660660
<item name="fieldset" xsi:type="string">other_settings/watermark/small_image</item>
661-
<item name="default" xsi:type="string">stretch</item>
662661
</item>
663662
<item name="watermark_thumbnail_size" xsi:type="array">
664663
<item name="path" xsi:type="string">design/watermark/thumbnail_size</item>
@@ -686,7 +685,6 @@
686685
<item name="watermark_thumbnail_position" xsi:type="array">
687686
<item name="path" xsi:type="string">design/watermark/thumbnail_position</item>
688687
<item name="fieldset" xsi:type="string">other_settings/watermark/thumbnail</item>
689-
<item name="default" xsi:type="string">stretch</item>
690688
</item>
691689
</argument>
692690
</arguments>

app/code/Magento/PageCache/etc/config.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
99
<default>
10+
<design>
11+
<invalid_caches>
12+
<full_page/>
13+
</invalid_caches>
14+
</design>
1015
<system>
1116
<full_page_cache>
1217
<varnish3>

app/code/Magento/Swatches/etc/config.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@
2020
</input_types>
2121
</validator_data>
2222
</general>
23+
<design>
24+
<watermark>
25+
<swatch_image_position>stretch</swatch_image_position>
26+
</watermark>
27+
</design>
2328
</default>
2429
</config>

app/code/Magento/Swatches/etc/di.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
<item name="watermark_swatch_image_position" xsi:type="array">
6262
<item name="path" xsi:type="string">design/watermark/swatch_image_position</item>
6363
<item name="fieldset" xsi:type="string">other_settings/watermark/swatch_image</item>
64-
<item name="default" xsi:type="string">stretch</item>
6564
</item>
6665
</argument>
6766
</arguments>

app/code/Magento/Theme/Model/Data/Design/ConfigFactory.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
use Magento\Theme\Api\Data\DesignConfigInterface;
1818
use Magento\Store\Model\ScopeInterface;
1919

20+
/**
21+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22+
*/
2023
class ConfigFactory
2124
{
2225
/**
@@ -96,8 +99,8 @@ public function create($scope, $scopeId, array $data = [])
9699
$configDataObject = $this->designConfigDataFactory->create();
97100
$configDataObject->setPath($metadata['path']);
98101
$configDataObject->setFieldConfig($metadata);
99-
if (isset($data[$name]) || isset($metadata['default'])) {
100-
$configDataObject->setValue(isset($data[$name]) ? $data[$name] : $metadata['default']);
102+
if (isset($data[$name])) {
103+
$configDataObject->setValue($data[$name]);
101104
}
102105
$configData[] = $configDataObject;
103106
}

app/code/Magento/Theme/Model/Design/Backend/Theme.php

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,51 @@ public function beforeSave()
6464
}
6565

6666
/**
67-
* {@inheritdoc}
68-
*
69-
* {@inheritdoc}. In addition, it sets status 'invalidate' for blocks and other output caches
67+
* Invalidate cache
7068
*
71-
* @return $this
69+
* @param bool $forceInvalidate
70+
* @return void
7271
*/
73-
public function afterSave()
72+
protected function invalidateCache($forceInvalidate = false)
7473
{
7574
$types = array_keys(
7675
$this->_config->getValue(
7776
self::XML_PATH_INVALID_CACHES,
7877
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
7978
)
8079
);
81-
if ($this->isValueChanged()) {
80+
if ($forceInvalidate || $this->isValueChanged()) {
8281
$this->cacheTypeList->invalidate($types);
8382
}
83+
}
8484

85+
/**
86+
* @return array
87+
*/
88+
public function getValue()
89+
{
90+
return $this->getData('value') != '' ? $this->getData('value') : null;
91+
}
92+
93+
/**
94+
* {@inheritdoc}
95+
*
96+
* {@inheritdoc}. In addition, it sets status 'invalidate' for blocks and other output caches
97+
*
98+
* @return $this
99+
*/
100+
public function afterSave()
101+
{
102+
$this->invalidateCache();
85103
return parent::afterSave();
86104
}
105+
106+
/**
107+
* {@inheritdoc}
108+
*/
109+
public function afterDelete()
110+
{
111+
$this->invalidateCache(true);
112+
return parent::afterDelete();
113+
}
87114
}

app/code/Magento/Theme/Test/Unit/Model/Design/Backend/ThemeTest.php

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
namespace Magento\Theme\Test\Unit\Model\Design\Backend;
88

99
use Magento\Framework\App\Area;
10+
use Magento\Framework\App\Config\ScopeConfigInterface;
1011
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
12+
use Magento\Store\Model\ScopeInterface;
1113
use Magento\Theme\Model\Design\Backend\Theme;
1214

1315
class ThemeTest extends \PHPUnit_Framework_TestCase
@@ -33,7 +35,7 @@ class ThemeTest extends \PHPUnit_Framework_TestCase
3335
protected $cacheTypeListMock;
3436

3537
/**
36-
* @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
38+
* @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
3739
*/
3840
protected $configMock;
3941

@@ -92,13 +94,13 @@ public function testAfterSave($callNumber, $oldValue)
9294
[
9395
[
9496
Theme::XML_PATH_INVALID_CACHES,
95-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
97+
ScopeInterface::SCOPE_STORE,
9698
null,
9799
['block_html' => 1, 'layout' => 1, 'translate' => 1]
98100
],
99101
[
100102
null,
101-
\Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
103+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
102104
null,
103105
$oldValue
104106
],
@@ -116,4 +118,31 @@ public function afterSaveDataProvider()
116118
[2, 'other_value'],
117119
];
118120
}
121+
122+
public function testAfterDelete()
123+
{
124+
$this->configMock->expects($this->any())
125+
->method('getValue')
126+
->willReturnMap(
127+
[
128+
[
129+
Theme::XML_PATH_INVALID_CACHES,
130+
ScopeInterface::SCOPE_STORE,
131+
null,
132+
['block_html' => 1, 'layout' => 1, 'translate' => 1]
133+
],
134+
[
135+
null,
136+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
137+
null,
138+
'old_value'
139+
],
140+
141+
]
142+
);
143+
$this->cacheTypeListMock->expects($this->exactly(2))
144+
->method('invalidate');
145+
$this->model->setValue('some_value');
146+
$this->assertSame($this->model, $this->model->afterDelete());
147+
}
119148
}

0 commit comments

Comments
 (0)