/**
  * Adds Select all choice.
  *
  * @param ChoicesAwareViewData $data
  * @param array                $list
  */
 private function addSelectAll(ChoicesAwareViewData $data, $list)
 {
     $parameters = $data->getUrlParameters();
     $parameters[$this->getRequestField()] = $list;
     $choice = new Choice();
     $choice->setLabel('label.missing_locale.all');
     $choice->setUrlParameters($parameters);
     $data->addChoice($choice);
 }
 /**
  * Creates locales list.
  *
  * @param ViewData\ChoicesAwareViewData $filter
  *
  * @return array
  */
 private function buildLocalesList($filter)
 {
     $search = $this->repository->createSearch();
     $localeAgg = new TermsAggregation('locale_agg');
     $localeAgg->setField('messages.locale');
     $search->addAggregation($localeAgg);
     $result = $this->repository->execute($search, Result::RESULTS_RAW);
     $list = [];
     foreach ($result['aggregations']['agg_locale_agg']['buckets'] as $value) {
         $list[$value['key']] = true;
     }
     ksort($list);
     $activeLocales = [];
     if ($filter->getState()->isActive()) {
         foreach ($filter->getChoices() as $choice) {
             $activeLocales[$choice->getLabel()] = $choice->isActive();
         }
         $list = array_merge($list, $activeLocales);
     }
     return $list;
 }