Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.4-develop' into bugfix/rest-ap…
Browse files Browse the repository at this point in the history
…i-pagination
  • Loading branch information
lbajsarowicz committed Feb 23, 2020
2 parents 11567f6 + 4dfb6da commit 6771122
Show file tree
Hide file tree
Showing 1,093 changed files with 35,104 additions and 7,654 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg)](https://crowdin.com/project/magento-2)
<p align="center">
<a href="https://magento.com">
<img src="https://static.magento.com/sites/all/themes/magento/logo.svg" width="300px" alt="Magento" />
</a>
</p>
<p align="center">
<br /><br />
<a href="https://www.codetriage.com/magento/magento2">
<img src="https://www.codetriage.com/magento/magento2/badges/users.svg" alt="Open Source Helpers" />
</a>
<a href="https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge">
<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Gitter" />
</a>
<a href="https://crowdin.com/project/magento-2">
<img src="https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg" alt="Crowdin" />
</a>
</p>

## Welcome
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/AdvancedPricingImportExport/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_AdvancedPricingImportExport" >
</module>
<module name="Magento_AdvancedPricingImportExport"/>
</config>
2 changes: 1 addition & 1 deletion app/code/Magento/Analytics/Model/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function __construct(
public function execute($commandName)
{
if (!array_key_exists($commandName, $this->commands)) {
throw new NotFoundException(__('Command was not found.'));
throw new NotFoundException(__('Command "%1" was not found.', $commandName));
}

/** @var \Magento\Analytics\Model\Connector\CommandInterface $command */
Expand Down
69 changes: 50 additions & 19 deletions app/code/Magento/Analytics/ReportXml/QueryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Analytics\ReportXml;

use Magento\Analytics\ReportXml\DB\SelectBuilderFactory;
use Magento\Framework\App\CacheInterface;
use Magento\Framework\DB\Select;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Serialize\Serializer\Json;

/**
* Creates Query object according to configuration
*
* Factory for @see \Magento\Analytics\ReportXml\Query
*/
class QueryFactory
Expand Down Expand Up @@ -45,6 +49,11 @@ class QueryFactory
*/
private $selectHydrator;

/**
* @var Json
*/
private $jsonSerializer;

/**
* QueryFactory constructor.
*
Expand All @@ -54,21 +63,24 @@ class QueryFactory
* @param SelectBuilderFactory $selectBuilderFactory
* @param Config $config
* @param array $assemblers
* @param Json $jsonSerializer
*/
public function __construct(
CacheInterface $queryCache,
SelectHydrator $selectHydrator,
ObjectManagerInterface $objectManager,
SelectBuilderFactory $selectBuilderFactory,
Config $config,
array $assemblers
array $assemblers,
Json $jsonSerializer
) {
$this->config = $config;
$this->selectBuilderFactory = $selectBuilderFactory;
$this->assemblers = $assemblers;
$this->queryCache = $queryCache;
$this->objectManager = $objectManager;
$this->selectHydrator = $selectHydrator;
$this->jsonSerializer = $jsonSerializer;
}

/**
Expand Down Expand Up @@ -101,14 +113,10 @@ private function constructQuery($queryName)
$selectBuilder = $assembler->assemble($selectBuilder, $queryConfig);
}
$select = $selectBuilder->create();
return $this->objectManager->create(
Query::class,
[
'select' => $select,
'selectHydrator' => $this->selectHydrator,
'connectionName' => $selectBuilder->getConnectionName(),
'config' => $queryConfig
]
return $this->createQueryObject(
$select,
$selectBuilder->getConnectionName(),
$queryConfig
);
}

Expand All @@ -122,19 +130,42 @@ public function create($queryName)
{
$cached = $this->queryCache->load($queryName);
if ($cached) {
$queryData = json_decode($cached, true);
return $this->objectManager->create(
Query::class,
[
'select' => $this->selectHydrator->recreate($queryData['select_parts']),
'selectHydrator' => $this->selectHydrator,
'connectionName' => $queryData['connectionName'],
'config' => $queryData['config']
]
$queryData = $this->jsonSerializer->unserialize($cached);
return $this->createQueryObject(
$this->selectHydrator->recreate($queryData['select_parts']),
$queryData['connectionName'],
$queryData['config']
);
}
$query = $this->constructQuery($queryName);
$this->queryCache->save(json_encode($query), $queryName);
$this->queryCache->save(
$this->jsonSerializer->serialize($query),
$queryName
);
return $query;
}

/**
* Create query class using objectmanger
*
* @param Select $select
* @param string $connection
* @param array $queryConfig
* @return Query
*/
private function createQueryObject(
Select $select,
string $connection,
array $queryConfig
) {
return $this->objectManager->create(
Query::class,
[
'select' => $select,
'selectHydrator' => $this->selectHydrator,
'connectionName' => $connection,
'config' => $queryConfig
]
);
}
}
6 changes: 5 additions & 1 deletion app/code/Magento/Analytics/Test/Unit/Model/ConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ public function testExecute()
}

/**
* Executing non-existing command
*
* @expectedException \Magento\Framework\Exception\NotFoundException
* @expectedExceptionMessage Command "register" was not found.
* @return void
*/
public function testExecuteCommandNotFound()
public function testExecuteCommandNotFound(): void
{
$commandName = 'register';
$this->connector->execute($commandName);
Expand Down
Loading

0 comments on commit 6771122

Please sign in to comment.