Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/DataTable/Row.php')
-rw-r--r--core/DataTable/Row.php30
1 files changed, 29 insertions, 1 deletions
diff --git a/core/DataTable/Row.php b/core/DataTable/Row.php
index 4c3ecc623b..f881f1cbf1 100644
--- a/core/DataTable/Row.php
+++ b/core/DataTable/Row.php
@@ -23,6 +23,8 @@ use Piwik\Metrics;
*/
class Row extends \ArrayObject
{
+ const COMPARISONS_METADATA_NAME = 'comparisons';
+
/**
* List of columns that cannot be summed. An associative array for speed.
*
@@ -87,9 +89,11 @@ class Row extends \ArrayObject
*/
public function export()
{
+ $metadataToPersist = $this->metadata;
+ unset($metadataToPersist[self::COMPARISONS_METADATA_NAME]);
return array(
self::COLUMNS => $this->getArrayCopy(),
- self::METADATA => $this->metadata,
+ self::METADATA => $metadataToPersist,
self::DATATABLE_ASSOCIATED => $this->subtableId,
);
}
@@ -591,6 +595,30 @@ class Row extends \ArrayObject
}
/**
+ * Returns the associated comparisons DataTable, if any.
+ *
+ * @return DataTable|null
+ */
+ public function getComparisons()
+ {
+ $dataTableId = $this->getMetadata(self::COMPARISONS_METADATA_NAME);
+ if (empty($dataTableId)) {
+ return null;
+ }
+ return Manager::getInstance()->getTable($dataTableId);
+ }
+
+ /**
+ * Associates the supplied table with this row as the comparisons table.
+ *
+ * @param DataTable $table
+ */
+ public function setComparisons(DataTable $table)
+ {
+ $this->setMetadata(self::COMPARISONS_METADATA_NAME, $table->getId());
+ }
+
+ /**
* Helper function: sums 2 values
*
* @param number|bool $thisColumnValue