コード例 #1
0
 /**
  * Validates the view configuration.
  * Fails if there is a non-image field, or there are more
  * than one image fields that are not excluded from display.
  */
 function validate()
 {
     $errors = parent::validate();
     if ($this->view->storage->isNew()) {
         // Skip validation when the view is being created.
         // (the default field is a title field, which would fail.)
         return $errors;
     }
     // Get a list of fields that have been added to the display.
     $fields = $this->displayHandler->handlers['field'];
     // Check if there is exactly one image field to display.
     $fields_valid = TRUE;
     $field_count = 0;
     foreach ($fields as $key => $field) {
         // Ignore fields excluded from display.
         if (!empty($field->options['exclude'])) {
             continue;
         }
         // Determine the field's type.
         $field_storage_definitions = \Drupal::entityManager()->getFieldStorageDefinitions($field->definition['entity_type']);
         $field_type = $field_storage_definitions[$field->field]->getType();
         if ($field_type != 'image') {
             // Cannot display non-image fields. That would break the image grid.
             $fields_valid = FALSE;
             break;
         }
         $field_count++;
     }
     if (!$fields_valid || $field_count > 1) {
         $errors[] = $this->t('This format can display only one image field and no other fields.');
     }
     return $errors;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function validate()
 {
     $errors = parent::validate();
     $pager_options = $this->displayHandler->getOption('pager');
     if (isset($pager_options['type']) && !($pager_options['type'] == 'none' || $pager_options['type'] == 'some')) {
         // @todo: Re-enable this error once issue #2579931 is resolved.
         // $errors[] = $this->stringTranslation->translate('The Juicebox style cannot be used with a pager. Please disable the "Use a pager" option for this display.');
     }
     $style = $this->displayHandler->getOption('style');
     // We want to somewhat "nag" the user if they have not yet configured the
     // Juicebox-specific plugin settings (because things won't work until they
     // do). However, we do NOT want to formally set an error. This is because
     // this validate method can run on pages where the user can't actaully touch
     // the Juicebox-specific plugin settings (such as
     // admin/structure/views/add).
     if (empty($style['options']['image_field']) || empty($style['options']['thumb_field'])) {
         drupal_set_message($this->stringTranslation->translate("To ensure a fully functional Juicebox gallery please remember to add at least one field of type Image, File or File ID to your Juicebox view display, and to configure all Juicebox Gallery format settings. Once you have completed these steps, re-save your view to remove this warning."), 'warning', FALSE);
     }
     return $errors;
 }
コード例 #3
0
ファイル: Calendar.php プロジェクト: CIGIHub/bsia-drupal8
 /**
  * {@inheritdoc}
  */
 public function validate()
 {
     $errors = parent::validate();
     $display_id = $this->displayHandler->display['id'];
     if ($display_id == 'default') {
         // @todo Update default display in templates to validate.
         return $errors;
     }
     // @todo Validate row plugin
     $argument = CalendarHelper::getDateArgumentHandler($this->view, $display_id);
     if (empty($argument)) {
         $errors[] = $this->t('\\Drupal\\calendar\\Plugin\\views\\style\\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.');
     }
     return $errors;
 }
コード例 #4
0
ファイル: FullCalendar.php プロジェクト: anatalsceo/en-classe
 /**
  * {@inheritdoc}
  */
 public function validate()
 {
     if ($this->displayHandler->display['display_plugin'] != 'default' && !$this->parseFields()) {
         drupal_set_message(t('Display "@display" requires at least one date field.', array('@display' => $this->displayHandler->display['display_title'])), 'error');
     }
     return parent::validate();
 }