当前位置: 首页>>代码示例>>PHP>>正文


PHP StylePluginBase::validate方法代码示例

本文整理汇总了PHP中Drupal\views\Plugin\views\style\StylePluginBase::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP StylePluginBase::validate方法的具体用法?PHP StylePluginBase::validate怎么用?PHP StylePluginBase::validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\views\Plugin\views\style\StylePluginBase的用法示例。


在下文中一共展示了StylePluginBase::validate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * 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;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:38,代码来源:PhotoGrid.php

示例2: validate

 /**
  * {@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;
 }
开发者ID:angelamaunz,项目名称:pccdemo,代码行数:23,代码来源:JuiceboxDisplayStyle.php

示例3: validate

 /**
  * {@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;
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:18,代码来源:Calendar.php

示例4: validate

 /**
  * {@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();
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:FullCalendar.php


注:本文中的Drupal\views\Plugin\views\style\StylePluginBase::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。