قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-22 15:07:44 +00:00

* Disable autosanitize for MultiSites API * Add proper type hints accross MultiSites plugin * cs/ws * Replace Common::getRequestVar with Request class methods * some more type hints * simplify table filter * updates expected UI test file * clean up more code & bring code to phpstan lvl 5 * Add tooltips to table header * small code improvements
58 خطوط
1.7 KiB
PHP
58 خطوط
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Matomo - free/libre analytics platform
|
|
*
|
|
* @link https://matomo.org
|
|
* @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
|
|
*/
|
|
|
|
namespace Piwik\Plugins\MultiSites\Columns\Metrics;
|
|
|
|
use Piwik\DataTable;
|
|
use Piwik\DataTable\Row;
|
|
use Piwik\Plugins\CoreHome\Columns\Metrics\EvolutionMetric;
|
|
use Piwik\Site;
|
|
|
|
/**
|
|
* Ecommerce evolution metric adapter. This is a special processed metric for MultiSites API methods. It will
|
|
* only be calculated for sites that have ecommerce enabled. The site is determined by the label
|
|
* of each row.
|
|
*/
|
|
class EcommerceOnlyEvolutionMetric extends EvolutionMetric
|
|
{
|
|
/** @var bool */
|
|
private $isRevenueEvolution;
|
|
|
|
public function __construct(
|
|
$wrapped,
|
|
DataTable $pastData,
|
|
$evolutionMetricName = false,
|
|
int $quotientPrecision = 0,
|
|
?DataTable $currentData = null
|
|
) {
|
|
parent::__construct($wrapped, $pastData, $evolutionMetricName, $quotientPrecision, $currentData);
|
|
|
|
$this->isRevenueEvolution = $this->getName() === 'revenue_evolution';
|
|
}
|
|
|
|
public function compute(Row $row)
|
|
{
|
|
$columnName = $this->getWrappedName();
|
|
$currentValue = $this->getMetric($row, $columnName);
|
|
|
|
// if the site this is for doesn't support ecommerce & this is for the revenue_evolution column,
|
|
// we don't add the new column
|
|
if ($currentValue === false || !$this->isRevenueEvolution) {
|
|
$idSite = $row->getMetadata('idsite');
|
|
if (!$idSite || !Site::isEcommerceEnabledFor($idSite)) {
|
|
$row->deleteColumn($columnName);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return parent::compute($row);
|
|
}
|
|
}
|