Esempio n. 1
0
 protected function configureSegments()
 {
     $brands = DeviceParserAbstract::$deviceBrands;
     $brandList = implode(", ", $brands);
     $segment = new Segment();
     $segment->setSegment('deviceBrand');
     $segment->setName('DevicesDetection_DeviceBrand');
     $segment->setAcceptedValues($brandList);
     $segment->setSqlFilter(function ($brand) use($brandList, $brands) {
         if ($brand == Piwik::translate('General_Unknown')) {
             return '';
         }
         $index = array_search(trim(urldecode($brand)), $brands);
         if ($index === false) {
             throw new \Exception("deviceBrand segment must be one of: {$brandList}");
         }
         return $index;
     });
     $this->addSegment($segment);
 }