diff options
9 files changed, 37 insertions, 30 deletions
diff --git a/core/Archive/DataTableFactory.php b/core/Archive/DataTableFactory.php index 71eaa7a8c1..59af8a4e0b 100644 --- a/core/Archive/DataTableFactory.php +++ b/core/Archive/DataTableFactory.php @@ -10,6 +10,7 @@ namespace Piwik\Archive; use Piwik\DataTable; +use Piwik\DataTable\DataTableInterface; use Piwik\DataTable\Row; use Piwik\Site; @@ -96,6 +97,23 @@ class DataTableFactory } /** + * Returns the ID of the site a table is related to based on the 'site' metadata entry, + * or null if there is none. + * + * @param DataTable $table + * @return int|null + */ + public static function getSiteIdFromMetadata(DataTable $table) + { + $site = $table->getMetadata('site'); + if (empty($site)) { + return null; + } else { + return $site->getId(); + } + } + + /** * Tells the factory instance to expand the DataTables that are created by * creating subtables and setting the subtable IDs of rows w/ subtables correctly. * @@ -345,10 +363,10 @@ class DataTableFactory * Converts site IDs and period string ranges into Site instances and * Period instances in DataTable metadata. */ - private function transformMetadata($table) + private function transformMetadata(DataTableInterface $table) { $periods = $this->periods; - $table->filter(function ($table) use ($periods) { + $table->filter(function (DataTable $table) use ($periods) { $table->setMetadata(DataTableFactory::TABLE_METADATA_SITE_INDEX, new Site($table->getMetadata(DataTableFactory::TABLE_METADATA_SITE_INDEX))); $table->setMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX, $periods[$table->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX)]); }); @@ -373,7 +391,7 @@ class DataTableFactory * @param $keyMetadata * @param $result */ - private function setTableMetadata($keyMetadata, $result) + private function setTableMetadata($keyMetadata, DataTableInterface $result) { if (!isset($keyMetadata[DataTableFactory::TABLE_METADATA_SITE_INDEX])) { $keyMetadata[DataTableFactory::TABLE_METADATA_SITE_INDEX] = reset($this->sitesId); @@ -385,7 +403,7 @@ class DataTableFactory } // Note: $result can be a DataTable\Map - $result->filter(function ($table) use ($keyMetadata) { + $result->filter(function (DataTable $table) use ($keyMetadata) { foreach ($keyMetadata as $name => $value) { $table->setMetadata($name, $value); } @@ -423,5 +441,4 @@ class DataTableFactory $result = $table; return $result; } -} - +}
\ No newline at end of file diff --git a/core/DataTable.php b/core/DataTable.php index bdb7ef4f99..61e8abb1eb 100644 --- a/core/DataTable.php +++ b/core/DataTable.php @@ -1679,21 +1679,4 @@ class DataTable implements DataTableInterface, \IteratorAggregate, \ArrayAccess { $this->deleteRow($offset); } - - /** - * Returns the ID of the site a table is related to based on the 'site' metadata entry, - * or null if there is none. - * - * @param DataTable $table - * @return int|null - */ - public static function getSiteIdFromMetadata(DataTable $table) - { - $site = $table->getMetadata('site'); - if (empty($site)) { - return null; - } else { - return $site->getId(); - } - } }
\ No newline at end of file diff --git a/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php b/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php index accd8dbf01..100aa134ed 100644 --- a/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php +++ b/core/DataTable/Filter/AddColumnsProcessedMetricsGoal.php @@ -8,6 +8,7 @@ */ namespace Piwik\DataTable\Filter; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Piwik; @@ -110,7 +111,7 @@ class AddColumnsProcessedMetricsGoal extends AddColumnsProcessedMetrics sort($goals); } - $idSite = DataTable::getSiteIdFromMetadata($table); + $idSite = GoalSpecificRevenuePerVisit::getSiteIdFromMetadata($table); $extraProcessedMetrics = $table->getMetadata(DataTable::EXTRA_PROCESSED_METRICS_METADATA_NAME); diff --git a/plugins/Goals/Columns/Metrics/AverageOrderRevenue.php b/plugins/Goals/Columns/Metrics/AverageOrderRevenue.php index a25d64c7e9..053477bf60 100644 --- a/plugins/Goals/Columns/Metrics/AverageOrderRevenue.php +++ b/plugins/Goals/Columns/Metrics/AverageOrderRevenue.php @@ -7,6 +7,7 @@ */ namespace Piwik\Plugins\Goals\Columns\Metrics; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Metrics\Formatter; @@ -54,7 +55,7 @@ class AverageOrderRevenue extends ProcessedMetric public function beforeFormat($report, DataTable $table) { - $this->idSite = DataTable::getSiteIdFromMetadata($table); + $this->idSite = DataTableFactory::getSiteIdFromMetadata($table); return !empty($this->idSite); // skip formatting if there is no site to get currency info from } }
\ No newline at end of file diff --git a/plugins/Goals/Columns/Metrics/AveragePrice.php b/plugins/Goals/Columns/Metrics/AveragePrice.php index 0ca06201e9..521ca15d17 100644 --- a/plugins/Goals/Columns/Metrics/AveragePrice.php +++ b/plugins/Goals/Columns/Metrics/AveragePrice.php @@ -8,6 +8,7 @@ namespace Piwik\Plugins\Goals\Columns\Metrics; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Metrics\Formatter; @@ -57,7 +58,7 @@ class AveragePrice extends ProcessedMetric public function beforeFormat($report, DataTable $table) { - $this->idSite = DataTable::getSiteIdFromMetadata($table); + $this->idSite = DataTableFactory::getSiteIdFromMetadata($table); return !empty($this->idSite); // skip formatting if there is no site to get currency info from } }
\ No newline at end of file diff --git a/plugins/Goals/Columns/Metrics/GoalSpecific/AverageOrderRevenue.php b/plugins/Goals/Columns/Metrics/GoalSpecific/AverageOrderRevenue.php index 19c23a5eff..845310e39c 100644 --- a/plugins/Goals/Columns/Metrics/GoalSpecific/AverageOrderRevenue.php +++ b/plugins/Goals/Columns/Metrics/GoalSpecific/AverageOrderRevenue.php @@ -7,6 +7,7 @@ */ namespace Piwik\Plugins\Goals\Columns\Metrics\GoalSpecific; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Metrics; @@ -61,7 +62,7 @@ class AverageOrderRevenue extends GoalSpecificProcessedMetric public function beforeFormat($report, DataTable $table) { - $this->idSite = DataTable::getSiteIdFromMetadata($table); + $this->idSite = DataTableFactory::getSiteIdFromMetadata($table); return !empty($this->idSite); // skip formatting if there is no site to get currency info from } }
\ No newline at end of file diff --git a/plugins/Goals/Columns/Metrics/GoalSpecific/Revenue.php b/plugins/Goals/Columns/Metrics/GoalSpecific/Revenue.php index 3d7e419a5d..27b5b9dad5 100644 --- a/plugins/Goals/Columns/Metrics/GoalSpecific/Revenue.php +++ b/plugins/Goals/Columns/Metrics/GoalSpecific/Revenue.php @@ -7,6 +7,7 @@ */ namespace Piwik\Plugins\Goals\Columns\Metrics\GoalSpecific; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Metrics; @@ -54,7 +55,7 @@ class Revenue extends GoalSpecificProcessedMetric public function beforeFormat($report, DataTable $table) { - $this->idSite = DataTable::getSiteIdFromMetadata($table); + $this->idSite = DataTableFactory::getSiteIdFromMetadata($table); return !empty($this->idSite); // skip formatting if there is no site to get currency info from } }
\ No newline at end of file diff --git a/plugins/Goals/Columns/Metrics/GoalSpecific/RevenuePerVisit.php b/plugins/Goals/Columns/Metrics/GoalSpecific/RevenuePerVisit.php index 5daceeb9c9..a90c1058d6 100644 --- a/plugins/Goals/Columns/Metrics/GoalSpecific/RevenuePerVisit.php +++ b/plugins/Goals/Columns/Metrics/GoalSpecific/RevenuePerVisit.php @@ -7,6 +7,7 @@ */ namespace Piwik\Plugins\Goals\Columns\Metrics\GoalSpecific; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Metrics; @@ -69,7 +70,7 @@ class RevenuePerVisit extends GoalSpecificProcessedMetric public function beforeFormat($report, DataTable $table) { - $this->idSite = DataTable::getSiteIdFromMetadata($table); + $this->idSite = DataTableFactory::getSiteIdFromMetadata($table); return !empty($this->idSite); // skip formatting if there is no site to get currency info from } }
\ No newline at end of file diff --git a/plugins/Goals/Columns/Metrics/RevenuePerVisit.php b/plugins/Goals/Columns/Metrics/RevenuePerVisit.php index b1912fe4e2..488d65c20a 100644 --- a/plugins/Goals/Columns/Metrics/RevenuePerVisit.php +++ b/plugins/Goals/Columns/Metrics/RevenuePerVisit.php @@ -7,6 +7,7 @@ */ namespace Piwik\Plugins\Goals\Columns\Metrics; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable; use Piwik\DataTable\Row; use Piwik\Metrics; @@ -77,7 +78,7 @@ class RevenuePerVisit extends ProcessedMetric public function beforeFormat($report, DataTable $table) { - $this->idSite = DataTable::getSiteIdFromMetadata($table); + $this->idSite = DataTableFactory::getSiteIdFromMetadata($table); return !empty($this->idSite); // skip formatting if there is no site to get currency info from } }
\ No newline at end of file |