123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Analytics\ReportXml;
- use Magento\Framework\DB\Select;
- /**
- * Query object, contains SQL statement, information about connection, query arguments
- */
- class Query implements \JsonSerializable
- {
- /**
- * @var Select
- */
- private $select;
- /**
- * @var \Magento\Analytics\ReportXml\SelectHydrator
- */
- private $selectHydrator;
- /**
- * @var string
- */
- private $connectionName;
- /**
- * @var array
- */
- private $config;
- /**
- * Query constructor.
- *
- * @param Select $select
- * @param SelectHydrator $selectHydrator
- * @param string $connectionName
- * @param array $config
- */
- public function __construct(
- Select $select,
- SelectHydrator $selectHydrator,
- $connectionName,
- $config
- ) {
- $this->select = $select;
- $this->connectionName = $connectionName;
- $this->selectHydrator = $selectHydrator;
- $this->config = $config;
- }
- /**
- * @return Select
- */
- public function getSelect()
- {
- return $this->select;
- }
- /**
- * @return string
- */
- public function getConnectionName()
- {
- return $this->connectionName;
- }
- /**
- * @return array
- */
- public function getConfig()
- {
- return $this->config;
- }
- /**
- * Specify data which should be serialized to JSON
- * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
- * @return mixed data which can be serialized by <b>json_encode</b>,
- * which is a value of any type other than a resource.
- */
- public function jsonSerialize()
- {
- return [
- 'connectionName' => $this->getConnectionName(),
- 'select_parts' => $this->selectHydrator->extract($this->getSelect()),
- 'config' => $this->getConfig()
- ];
- }
- }
|