Skip to content

Commit d96ace4

Browse files
authored
Merge pull request #43 from magento/develop
Merge develop into MAGETWO-62660
2 parents 30ba972 + 1507bb1 commit d96ace4

File tree

44 files changed

+1073
-273
lines changed

Some content is hidden

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

44 files changed

+1073
-273
lines changed

app/code/Magento/Backup/Controller/Adminhtml/Index/Grid.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
*/
77
namespace Magento\Backup\Controller\Adminhtml\Index;
88

9+
use Magento\Framework\Controller\ResultFactory;
10+
911
class Grid extends \Magento\Backup\Controller\Adminhtml\Index
1012
{
1113
/**
1214
* Backup list action
1315
*
14-
* @return void
16+
* @return \Magento\Framework\Controller\ResultInterface
1517
*/
1618
public function execute()
1719
{
18-
$this->_view->loadLayout();
19-
$this->_view->renderLayout();
20+
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
2021
}
2122
}

app/code/Magento/Catalog/view/frontend/templates/product/view/attributes.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
?>
1515
<?php
1616
$_helper = $this->helper('Magento\Catalog\Helper\Output');
17-
$_product = $block->getProduct()
17+
$_product = $block->getProduct();
1818
?>
1919
<?php if ($_additional = $block->getAdditionalData()): ?>
2020
<div class="additional-attributes-wrapper table-wrapper">

app/code/Magento/CatalogSearch/Controller/Advanced/Index.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
*/
77
namespace Magento\CatalogSearch\Controller\Advanced;
88

9+
use Magento\Framework\Controller\ResultFactory;
10+
911
class Index extends \Magento\Framework\App\Action\Action
1012
{
1113
/**
12-
* @return void
14+
* @return \Magento\Framework\Controller\ResultInterface
1315
*/
1416
public function execute()
1517
{
16-
$this->_view->loadLayout();
17-
$this->_view->renderLayout();
18+
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
1819
}
1920
}

app/code/Magento/Cms/Model/ResourceModel/Block/Grid/Collection.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@ public function setAggregations($aggregations)
8484
$this->aggregations = $aggregations;
8585
}
8686

87-
/**
88-
* Retrieve all ids for collection
89-
* Backward compatibility with EAV collection
90-
*
91-
* @param int $limit
92-
* @param int $offset
93-
* @return array
94-
*/
95-
public function getAllIds($limit = null, $offset = null)
96-
{
97-
return $this->getConnection()->fetchCol($this->_getAllIdsSelect($limit, $offset), $this->_bindParams);
98-
}
99-
10087
/**
10188
* Get search criteria.
10289
*

app/code/Magento/Contact/Controller/Index/Index.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66
*/
77
namespace Magento\Contact\Controller\Index;
88

9+
use Magento\Framework\Controller\ResultFactory;
10+
911
class Index extends \Magento\Contact\Controller\Index
1012
{
1113
/**
1214
* Show Contact Us page
1315
*
14-
* @return void
16+
* @return \Magento\Framework\Controller\ResultInterface
1517
*/
1618
public function execute()
1719
{
18-
$this->_view->loadLayout();
19-
$this->_view->renderLayout();
20+
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
2021
}
2122
}

app/code/Magento/Contact/Test/Unit/Controller/Index/IndexTest.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace Magento\Contact\Test\Unit\Controller\Index;
88

9+
use Magento\Framework\Controller\ResultFactory;
10+
use Magento\Framework\Controller\ResultInterface;
11+
912
class IndexTest extends \PHPUnit_Framework_TestCase
1013
{
1114
/**
@@ -25,7 +28,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase
2528
* View mock
2629
* @var \Magento\Framework\App\ViewInterface|\PHPUnit_Framework_MockObject_MockObject
2730
*/
28-
protected $_view;
31+
protected $resultFactory;
2932

3033
/**
3134
* Url mock
@@ -43,7 +46,7 @@ protected function setUp()
4346
);
4447
$context = $this->getMock(
4548
\Magento\Framework\App\Action\Context::class,
46-
['getRequest', 'getResponse', 'getView', 'getUrl'],
49+
['getRequest', 'getResponse', 'getResultFactory', 'getUrl'],
4750
[],
4851
'',
4952
false
@@ -67,17 +70,17 @@ protected function setUp()
6770
$this->getMockForAbstractClass(\Magento\Framework\App\ResponseInterface::class, [], '', false)
6871
));
6972

70-
$this->_view = $this->getMock(
71-
\Magento\Framework\App\ViewInterface::class,
73+
$this->resultFactory = $this->getMock(
74+
ResultFactory::class,
7275
[],
7376
[],
7477
'',
7578
false
7679
);
7780

7881
$context->expects($this->once())
79-
->method('getView')
80-
->will($this->returnValue($this->_view));
82+
->method('getResultFactory')
83+
->will($this->returnValue($this->resultFactory));
8184

8285
$this->_controller = new \Magento\Contact\Controller\Index\Index(
8386
$context,
@@ -90,12 +93,12 @@ protected function setUp()
9093

9194
public function testExecute()
9295
{
93-
$this->_view->expects($this->once())
94-
->method('loadLayout');
95-
96-
$this->_view->expects($this->once())
97-
->method('renderLayout');
96+
$resultStub = $this->getMockForAbstractClass(ResultInterface::class);
97+
$this->resultFactory->expects($this->once())
98+
->method('create')
99+
->with(ResultFactory::TYPE_PAGE)
100+
->willReturn($resultStub);
98101

99-
$this->_controller->execute();
102+
$this->assertSame($resultStub, $this->_controller->execute());
100103
}
101104
}

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

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

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Framework\View\Design\ThemeInterface;
910
use Magento\Theme\Model\ResourceModel\Theme\Collection as ThemeCollection;
1011

@@ -78,6 +79,11 @@ class Theme extends \Magento\Framework\Model\AbstractModel implements ThemeInter
7879
*/
7980
protected $_customFactory;
8081

82+
/**
83+
* @var ThemeFactory
84+
*/
85+
private $themeModelFactory;
86+
8187
/**
8288
* @var ThemeInterface[]
8389
*/
@@ -96,7 +102,7 @@ class Theme extends \Magento\Framework\Model\AbstractModel implements ThemeInter
96102
* @param \Magento\Theme\Model\ResourceModel\Theme $resource
97103
* @param \Magento\Theme\Model\ResourceModel\Theme\Collection $resourceCollection
98104
* @param array $data
99-
*
105+
* @param ThemeFactory $themeModelFactory
100106
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
101107
*/
102108
public function __construct(
@@ -109,14 +115,16 @@ public function __construct(
109115
\Magento\Framework\View\Design\Theme\CustomizationFactory $customizationFactory,
110116
\Magento\Theme\Model\ResourceModel\Theme $resource = null,
111117
ThemeCollection $resourceCollection = null,
112-
array $data = []
118+
array $data = [],
119+
ThemeFactory $themeModelFactory = null
113120
) {
114121
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
115122
$this->_themeFactory = $themeFactory;
116123
$this->_domainFactory = $domainFactory;
117124
$this->_imageFactory = $imageFactory;
118125
$this->_validator = $validator;
119126
$this->_customFactory = $customizationFactory;
127+
$this->themeModelFactory = $themeModelFactory ?: ObjectManager::getInstance()->get(ThemeFactory::class);
120128
$this->addData(['type' => self::TYPE_VIRTUAL]);
121129
}
122130

@@ -377,52 +385,54 @@ public function getInheritedThemes()
377385
}
378386

379387
/**
380-
* {@inheritdoc}
388+
* @inheritdoc
381389
*/
382-
public function __sleep()
390+
public function toArray(array $keys = [])
383391
{
384-
$properties = parent::__sleep();
385-
$key = array_search('_logger', $properties);
386-
if (false !== $key) {
387-
unset($properties[$key]);
392+
$data = parent::toArray($keys);
393+
if (isset($data['parent_theme'])) {
394+
$data['parent_theme'] = $this->getParentTheme()->toArray();
388395
}
389-
return array_diff(
390-
$properties,
391-
[
392-
'_resource',
393-
'_resourceCollection',
394-
'_themeFactory',
395-
'_domainFactory',
396-
'_imageFactory',
397-
'_validator',
398-
'_customFactory'
399-
]
400-
);
396+
397+
if (isset($data['inherited_themes'])) {
398+
foreach ($data['inherited_themes'] as $key => $inheritedTheme) {
399+
$data['inherited_themes'][$key] = $inheritedTheme->toArray();
400+
}
401+
}
402+
403+
return $data;
401404
}
402405

403406
/**
404-
* {@inheritdoc}
407+
* Populate Theme object from an array
408+
*
409+
* @param array $data
410+
* @return Theme
405411
*/
406-
public function __wakeup()
412+
public function populateFromArray(array $data)
407413
{
408-
parent::__wakeup();
409-
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
410-
$this->_resource = $objectManager->get(\Magento\Theme\Model\ResourceModel\Theme::class);
411-
$this->_resourceCollection = $objectManager->get(\Magento\Theme\Model\ResourceModel\Theme\Collection::class);
412-
$this->_themeFactory = $objectManager->get(\Magento\Framework\View\Design\Theme\FlyweightFactory::class);
413-
$this->_domainFactory = $objectManager->get(\Magento\Framework\View\Design\Theme\Domain\Factory::class);
414-
$this->_imageFactory = $objectManager->get(\Magento\Framework\View\Design\Theme\ImageFactory::class);
415-
$this->_validator = $objectManager->get(\Magento\Framework\View\Design\Theme\Validator::class);
416-
$this->_customFactory = $objectManager->get(\Magento\Framework\View\Design\Theme\CustomizationFactory::class);
414+
$this->_data = $data;
415+
if (isset($data['parent_theme'])) {
416+
$this->_data['parent_theme'] = $this->createThemeInstance()->populateFromArray($data['parent_theme']);
417+
}
418+
419+
if (isset($data['inherited_themes'])) {
420+
foreach ($data['inherited_themes'] as $key => $inheritedTheme) {
421+
$themeInstance = $this->createThemeInstance()->populateFromArray($inheritedTheme);
422+
$this->_data['inherited_themes'][$key] = $themeInstance;
423+
}
424+
}
425+
426+
return $this;
417427
}
418428

419429
/**
420-
* @param int $modelId
421-
* @param null $field
422-
* @return $this
430+
* Create Theme instance
431+
*
432+
* @return \Magento\Theme\Model\Theme
423433
*/
424-
public function load($modelId, $field = null)
434+
private function createThemeInstance()
425435
{
426-
return parent::load($modelId, $field); // TODO: Change the autogenerated stub
436+
return $this->themeModelFactory->create();
427437
}
428438
}

0 commit comments

Comments
 (0)