Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function overviewSearchFormPart(array $form, FormStateInterface $form_state, $type)
 {
     $form = parent::overviewSearchFormPart($form, $form_state, $type);
     $options = array();
     foreach (\Drupal::languageManager()->getLanguages() as $langcode => $language) {
         $options[$langcode] = $language->getName();
     }
     $default_values = $this->getSearchFormSubmittedParams();
     $form['search_wrapper']['search']['label'] = array('#type' => 'textfield', '#title' => t('Source text'), '#default_value' => isset($default_values['label']) ? $default_values['label'] : NULL);
     // Unset English as it is the source language for all locale strings.
     unset($options['en']);
     $form['search_wrapper']['search']['missing_target_language'] = array('#type' => 'select', '#title' => t('Not translated to'), '#options' => $options, '#empty_option' => '--', '#default_value' => isset($default_values['missing_target_language']) ? $default_values['missing_target_language'] : NULL);
     return $form;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function overviewForm(array $form, FormStateInterface $form_state, $type)
 {
     $form = parent::overviewForm($form, $form_state, $type);
     // Load search property params which will be passed into
     $search_property_params = array();
     $exclude_params = array('q', 'page');
     foreach (\Drupal::request()->query->all() as $key => $value) {
         // Skip exclude params, and those that have empty values, as these would
         // make it into query condition instead of being ignored.
         if (in_array($key, $exclude_params) || $value === '') {
             continue;
         }
         $search_property_params[$key] = $value;
     }
     // If the source is of type '_simple_config', we get all definitions that
     // don't have an entity type and display them through overviewRowSimple().
     if ($type == ConfigSource::SIMPLE_CONFIG) {
         $definitions = $this->getFilteredSimpleConfigDefinitions($search_property_params);
         foreach ($definitions as $definition_id => $definition) {
             $form['items']['#options'][$definition_id] = $this->overviewRowSimple($definition);
         }
     } else {
         foreach ($this->getTranslatableEntities($type, $search_property_params) as $entity) {
             $form['items']['#options'][$entity->getConfigDependencyName()] = $this->overviewRow($entity);
         }
     }
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function overviewForm(array $form, FormStateInterface $form_state, $type)
 {
     $form = parent::overviewForm($form, $form_state, $type);
     // Build a list of allowed search conditions and get their values from the request.
     $entity_type = \Drupal::entityManager()->getDefinition($type);
     $whitelist = array('langcode', 'target_language', 'target_status');
     if ($entity_type->hasKey('bundle')) {
         $whitelist[] = $entity_type->getKey('bundle');
     }
     if ($entity_type->hasKey('label')) {
         $whitelist[] = $entity_type->getKey('label');
     }
     $search_property_params = array_filter(\Drupal::request()->query->all());
     $search_property_params = array_intersect_key($search_property_params, array_flip($whitelist));
     $bundles = $this->getTranslatableBundles($type);
     foreach (self::getTranslatableEntities($type, $search_property_params, TRUE) as $entity) {
         // This occurs on user entity type.
         if ($entity->id()) {
             $form['items']['#options'][$entity->id()] = $this->overviewRow($entity, $bundles);
         }
     }
     $form['pager'] = array('#type' => 'pager');
     return $form;
 }