diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-11-18 05:05:49 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-11-18 05:05:49 +0400 |
commit | 884e22d596b4b5be15fc6e33bb2403f021bfeb58 (patch) | |
tree | 9ad43b6828765571366f27a8e65114db643fa311 /core | |
parent | ba372fe35080bc758c43a0ffdf83cb5d5dec16ce (diff) |
Refactor const to highlight their coupling #4278
Diffstat (limited to 'core')
-rw-r--r-- | core/API/DataTableManipulator.php | 3 | ||||
-rw-r--r-- | core/Archive.php | 2 | ||||
-rw-r--r-- | core/Archive/DataTableFactory.php | 7 | ||||
-rw-r--r-- | core/DataTable/Renderer/Rss.php | 5 | ||||
-rw-r--r-- | core/Site.php | 13 |
5 files changed, 23 insertions, 7 deletions
diff --git a/core/API/DataTableManipulator.php b/core/API/DataTableManipulator.php index b85a28a707..f85b653200 100644 --- a/core/API/DataTableManipulator.php +++ b/core/API/DataTableManipulator.php @@ -11,6 +11,7 @@ namespace Piwik\API; use Exception; +use Piwik\Archive\DataTableFactory; use Piwik\DataTable\Row; use Piwik\DataTable; use Piwik\Period\Range; @@ -119,7 +120,7 @@ abstract class DataTableManipulator $request['idSubtable'] = $idSubTable; if ($dataTable) { - $period = $dataTable->getMetadata('period'); + $period = $dataTable->getMetadata(DataTableFactory::TABLE_METADATA_PERIOD_INDEX); if ($period instanceof Range) { $request['date'] = $period->getDateStart() . ',' . $period->getDateEnd(); } else { diff --git a/core/Archive.php b/core/Archive.php index 1f9d571fb8..f1627a8eb1 100644 --- a/core/Archive.php +++ b/core/Archive.php @@ -712,7 +712,7 @@ class Archive * whether archiving should be launched based on whether $this->idarchives has a * an entry for a specific 'done' flag. * - * If this function is not called, then periods with no visits will not add + * If this function is not called, then periods with no visits will not add * entries to the cache. If the archive is used again, SQL will be executed to * try and find the archive IDs even though we know there are none. */ diff --git a/core/Archive/DataTableFactory.php b/core/Archive/DataTableFactory.php index ab6cd5e568..a053c6b09c 100644 --- a/core/Archive/DataTableFactory.php +++ b/core/Archive/DataTableFactory.php @@ -80,6 +80,9 @@ class DataTableFactory */ private $defaultRow; + const TABLE_METADATA_SITE_INDEX = 'site'; + const TABLE_METADATA_PERIOD_INDEX = 'period'; + /** * Constructor. */ @@ -383,8 +386,8 @@ class DataTableFactory { $periods = $this->periods; $table->filter(function ($table) use ($periods) { - $table->setMetadata('site', new Site($table->getMetadata('site'))); - $table->setMetadata('period', $periods[$table->getMetadata('period')]); + $table->setMetadata(self::TABLE_METADATA_SITE_INDEX, new Site($table->getMetadata(self::TABLE_METADATA_SITE_INDEX))); + $table->setMetadata(self::TABLE_METADATA_PERIOD_INDEX, $periods[$table->getMetadata(self::TABLE_METADATA_PERIOD_INDEX)]); }); } diff --git a/core/DataTable/Renderer/Rss.php b/core/DataTable/Renderer/Rss.php index dee117a90f..d9eadf9afd 100644 --- a/core/DataTable/Renderer/Rss.php +++ b/core/DataTable/Renderer/Rss.php @@ -11,6 +11,7 @@ namespace Piwik\DataTable\Renderer; use Exception; +use Piwik\Archive; use Piwik\Common; use Piwik\DataTable\Renderer; use Piwik\DataTable; @@ -75,8 +76,8 @@ class Rss extends Renderer $moreRecentFirst = array_reverse($table->getDataTables(), true); foreach ($moreRecentFirst as $date => $subtable) { /** @var DataTable $subtable */ - $timestamp = $subtable->getMetadata('period')->getDateStart()->getTimestamp(); - $site = $subtable->getMetadata('site'); + $timestamp = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_PERIOD_INDEX)->getDateStart()->getTimestamp(); + $site = $subtable->getMetadata(Archive\DataTableFactory::TABLE_METADATA_SITE_INDEX); $pudDate = date('r', $timestamp); diff --git a/core/Site.php b/core/Site.php index 9d14ead63c..bcbf0572ff 100644 --- a/core/Site.php +++ b/core/Site.php @@ -72,6 +72,15 @@ class Site } /** + * @param $idsite + * @param $site + */ + protected static function setSite($idsite, $site) + { + self::$infoSites[$idsite] = $site; + } + + /** * Sets the cached Site data with a non-associated array of site data. * * @param array $sites The array of sites data. eg, @@ -91,6 +100,7 @@ class Site self::setSites($sitesById); } + /** * Returns a string representation of the site this instance references. * @@ -313,7 +323,8 @@ class Site $idsite = (int)$idsite; if (!isset(self::$infoSites[$idsite])) { - self::$infoSites[$idsite] = API::getInstance()->getSiteFromId($idsite); + $site = API::getInstance()->getSiteFromId($idsite); + self::setSite($idsite, $site); } return self::$infoSites[$idsite][$field]; |