diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-28 13:55:14 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-08-28 13:55:14 +0400 |
commit | f9219dff1bcb5b21bccc56c5b09b5de68cdc3a2b (patch) | |
tree | 583fd99247b75643d8c51e8f8dc25a21100706f8 /plugins/Contents/Dimensions.php | |
parent | 10ecff50c3e25cab6501dbc73a1c64131e21db7e (diff) |
refs #4996 I learned the secondary dimension is not needed in my case. Makes it simpler and now the correct label is displayed in a subtable. I should not copy/paste code that I do not understand :)
Diffstat (limited to 'plugins/Contents/Dimensions.php')
-rw-r--r-- | plugins/Contents/Dimensions.php | 81 |
1 files changed, 12 insertions, 69 deletions
diff --git a/plugins/Contents/Dimensions.php b/plugins/Contents/Dimensions.php index aab79450ca..ce74022924 100644 --- a/plugins/Contents/Dimensions.php +++ b/plugins/Contents/Dimensions.php @@ -10,81 +10,24 @@ namespace Piwik\Plugins\Contents; class Dimensions { - - private static $defaultMappingApiToSecondaryDimension = array( - 'getContentNames' => 'getContentPieces', - 'getContentPieces' => 'getContentNames' - ); - - private static $mappingApiToRecord = array( - 'getContentNames' => array( - 'getContentPieces' => Archiver::CONTENTS_NAME_PIECE_RECORD_NAME - ), - 'getContentPieces' => array( - 'getContentNames' => Archiver::CONTENTS_PIECE_NAME_RECORD_NAME, - ) - ); - - public static function getDefaultSecondaryDimension($apiMethod) - { - if (isset(self::$defaultMappingApiToSecondaryDimension[$apiMethod])) { - return self::$defaultMappingApiToSecondaryDimension[$apiMethod]; - } - - return false; - } - - public static function getRecordNameForAction($apiMethod, $secondaryDimension = false) - { - if (empty($secondaryDimension)) { - $secondaryDimension = self::getDefaultSecondaryDimension($apiMethod); - } - - $record = self::$mappingApiToRecord[$apiMethod]; - if (!is_array($record)) { - return $record; - } - - // when secondaryDimension is incorrectly set - if (empty($record[$secondaryDimension])) { - return key($record); - } - - return $record[$secondaryDimension]; - } - - /** - * @ignore - * @param $apiMethod - * @return array - */ - public static function getSecondaryDimensions($apiMethod) + public static function getRecordNameForAction($apiMethod) { - $records = self::$mappingApiToRecord[$apiMethod]; - - if(!is_array($records)) { - return false; - } + $apiToRecord = array( + 'getContentNames' => Archiver::CONTENTS_NAME_PIECE_RECORD_NAME, + 'getContentPieces' => Archiver::CONTENTS_PIECE_NAME_RECORD_NAME + ); - return array_keys($records); + return $apiToRecord[$apiMethod]; } - public static function checkSecondaryDimension($apiMethod, $secondaryDimension) + public static function getSubtableLabelForApiMethod($apiMethod) { - if (empty($secondaryDimension)) { - return; - } - - $isSecondaryDimensionValid = - isset(self::$mappingApiToRecord[$apiMethod]) - && isset(self::$mappingApiToRecord[$apiMethod][$secondaryDimension]); + $labelToMethod = array( + 'getContentNames' => 'Contents_ContentPiece', + 'getContentPieces' => 'Contents_ContentName' + ); - if (!$isSecondaryDimensionValid) { - throw new \Exception( - "Secondary dimension '$secondaryDimension' is not valid for the API $apiMethod. ". - "Use one of: " . implode(", ", self::getSecondaryDimensions($apiMethod)) - ); - } + return $labelToMethod[$apiMethod]; } } |