2020-10-13 19:21:27 +01:00
|
|
|
<?php
|
|
|
|
|
2020-10-27 10:06:32 +00:00
|
|
|
namespace App\Legacy\Statistics;
|
2020-10-13 19:21:27 +01:00
|
|
|
|
|
|
|
use App\Entity\Statistic;
|
2020-12-14 11:02:40 +00:00
|
|
|
use App\Legacy\Data\PresetDataHandlers\SubpanelDataQueryHandler;
|
2020-10-13 19:21:27 +01:00
|
|
|
use App\Service\StatisticsProviderInterface;
|
|
|
|
|
2020-12-14 11:02:40 +00:00
|
|
|
class SubpanelDefault extends SubpanelDataQueryHandler implements StatisticsProviderInterface
|
2020-10-13 19:21:27 +01:00
|
|
|
{
|
2020-12-14 11:02:40 +00:00
|
|
|
use StatisticsHandlingTrait;
|
|
|
|
|
2020-10-13 19:21:27 +01:00
|
|
|
public const KEY = 'default';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getKey(): string
|
|
|
|
{
|
|
|
|
return self::KEY;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2020-12-14 11:02:40 +00:00
|
|
|
public function getData(array $query): Statistic
|
2020-10-13 19:21:27 +01:00
|
|
|
{
|
2020-12-14 11:02:40 +00:00
|
|
|
$subpanel = $query['key'];
|
|
|
|
[$module, $id] = $this->extractContext($query);
|
2020-12-08 16:15:13 +00:00
|
|
|
if (empty($module) || empty($id)) {
|
2020-12-14 11:02:40 +00:00
|
|
|
return $this->getEmptyResponse(self::KEY);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->init();
|
|
|
|
$this->startLegacyApp();
|
|
|
|
|
|
|
|
$queries = $this->getQueries($module, $id, $subpanel);
|
|
|
|
$parts = $queries[0];
|
|
|
|
$parts['select'] = 'SELECT COUNT(*) as value';
|
2020-10-13 19:21:27 +01:00
|
|
|
|
2020-12-14 11:02:40 +00:00
|
|
|
$dbQuery = $this->joinQueryParts($parts);
|
|
|
|
$result = $this->fetchRow($dbQuery);
|
|
|
|
$statistic = $this->buildSingleValueResponse(self::KEY, 'int', $result);
|
2020-10-13 19:21:27 +01:00
|
|
|
|
2020-12-14 11:02:40 +00:00
|
|
|
$this->close();
|
2020-10-13 19:21:27 +01:00
|
|
|
return $statistic;
|
|
|
|
}
|
|
|
|
}
|