예제 #1
0
파일: ActionType.php 프로젝트: cemo/piwik
 protected function configureSegments()
 {
     $types = $this->types;
     $segment = new Segment();
     $segment->setSegment('actionType');
     $segment->setName('Actions_ActionType');
     $segment->setSqlSegment('log_action.type');
     $segment->setType(Segment::TYPE_METRIC);
     $segment->setAcceptedValues(sprintf('A type of action, such as: %s', implode(', ', $types)));
     $segment->setSqlFilter(function ($type) use($types) {
         if (array_key_exists($type, $types)) {
             return $type;
         }
         $index = array_search(strtolower(trim(urldecode($type))), $types);
         if ($index === false) {
             throw new Exception("actionType must be one of: " . implode(', ', $types));
         }
         return $index;
     });
     $segment->setSuggestedValuesCallback(function ($idSite, $maxSuggestionsToReturn) use($types) {
         return array_slice(array_values($types), 0, $maxSuggestionsToReturn);
     });
     $this->addSegment($segment);
 }