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


PHP Field\FormatterBase类代码示例

本文整理汇总了PHP中Drupal\Core\Field\FormatterBase的典型用法代码示例。如果您正苦于以下问题:PHP FormatterBase类的具体用法?PHP FormatterBase怎么用?PHP FormatterBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: settingsForm

  public function settingsForm(array $form, FormStateInterface $form_state) {
    $elements = parent::settingsForm($form, $form_state);

    $elements['keep_pdfjs'] = array(
      '#type' => 'checkbox',
      '#title' => t('Always use pdf.js'),
      '#default_value' => $this->getSetting('keep_pdfjs'),
      '#description' => t("Use pdf.js even the browser has Adobe Reader Plugin, WebKit PDF Reader for Safari or the PDF Reader for Chrome (Chrome's default alternative to the Adobe Reader Plugin) installed."),
    );

    $elements['width'] = array(
      '#type' => 'textfield',
      '#title' => 'Width',
      '#default_value' => $this->getSetting('width'),
      '#description' => t('Width of the viewer. Ex: 250px or 100%'),
    );

    $elements['height'] = array(
      '#type' => 'textfield',
      '#title' => 'Height',
      '#default_value' => $this->getSetting('height'),
      '#description' => t('Height of the viewer. Ex: 250px or 100%'),
    );
    return $elements;
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:25,代码来源:PdfDefault.php

示例2: view

 /**
  * {@inheritdoc}
  *
  * @see ::prepareView()
  * @see ::getEntitiestoView()
  */
 public function view(FieldItemListInterface $items, $langcode = NULL)
 {
     $elements = parent::view($items, $langcode);
     $field_level_access_cacheability = new CacheableMetadata();
     // Try to map the cacheability of the access result that was set at
     // _accessCacheability in getEntitiesToView() to the corresponding render
     // subtree. If no such subtree is found, then merge it with the field-level
     // access cacheability.
     foreach ($items as $delta => $item) {
         // Ignore items for which access cacheability could not be determined in
         // prepareView().
         if (!empty($item->_accessCacheability)) {
             if (isset($elements[$delta])) {
                 CacheableMetadata::createFromRenderArray($elements[$delta])->merge($item->_accessCacheability)->applyTo($elements[$delta]);
             } else {
                 $field_level_access_cacheability = $field_level_access_cacheability->merge($item->_accessCacheability);
             }
         }
     }
     // Apply the cacheability metadata for the inaccessible entities and the
     // entities for which the corresponding render subtree could not be found.
     // This causes the field to be rendered (and cached) according to the cache
     // contexts by which the access results vary, to ensure only users with
     // access to this field can view it. It also tags this field with the cache
     // tags on which the access results depend, to ensure users that cannot view
     // this field at the moment will gain access once any of those cache tags
     // are invalidated.
     $field_level_access_cacheability->applyTo($elements);
     return $elements;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:36,代码来源:EntityReferenceFormatterBase.php

示例3: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $form['check_in_date_format'] = array('#type' => 'textfield', '#title' => $this->t('Check-in date/time format'), '#description' => $this->t('See <a href=":url" target="_blank">the documentation for PHP date formats</a>.', [':url' => 'http://php.net/manual/function.date.php']), '#default_value' => $this->getSetting('check_in_date_format'));
     $form['check_out_date_format'] = array('#type' => 'textfield', '#title' => $this->t('Check-out date/time format'), '#description' => $this->t('See <a href=":url" target="_blank">the documentation for PHP date formats</a>.', [':url' => 'http://php.net/manual/function.date.php']), '#default_value' => $this->getSetting('check_out_date_format'));
     return $form;
 }
开发者ID:lokeoke,项目名称:d8intranet,代码行数:10,代码来源:CheckInAndOutDefaultFormatter.php

示例4: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $entity_type = $this->entityManager->getDefinition($this->fieldDefinition->getTargetEntityTypeId());
     $form['link_to_entity'] = ['#type' => 'checkbox', '#title' => $this->t('Link to the @entity_label', ['@entity_label' => $entity_type->getLabel()]), '#default_value' => $this->getSetting('link_to_entity')];
     return $form;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:StringFormatter.php

示例5: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $settings = $this->getSettings();
     $formatters = $settings['formatters'];
     $this->prepareFormatters($this->fieldDefinition->getType(), $formatters, FALSE);
     $elements['#attached']['library'][] = 'fallback_formatter/admin';
     $parents = array('fields', $this->fieldDefinition->getName(), 'settings_edit_form', 'settings', 'formatters');
     // Filter status.
     $elements['formatters']['status'] = array('#type' => 'item', '#title' => t('Enabled formatters'), '#prefix' => '<div class="fallback-formatter-status-wrapper">', '#suffix' => '</div>');
     foreach ($formatters as $name => $options) {
         $elements['formatters']['status'][$name] = array('#type' => 'checkbox', '#title' => $options['label'], '#default_value' => !empty($options['status']), '#parents' => array_merge($parents, array($name, 'status')), '#weight' => $options['weight']);
     }
     // Filter order (tabledrag).
     $elements['formatters']['order'] = array('#type' => 'item', '#title' => t('Formatter processing order'), '#theme' => 'fallback_formatter_settings_order');
     foreach ($formatters as $name => $options) {
         $elements['formatters']['order'][$name]['label'] = array('#markup' => $options['label']);
         $elements['formatters']['order'][$name]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $options['label'])), '#title_display' => 'invisible', '#delta' => 50, '#default_value' => $options['weight'], '#parents' => array_merge($parents, array($name, 'weight')));
         $elements['formatters']['order'][$name]['#weight'] = $options['weight'];
     }
     // Filter settings.
     foreach ($formatters as $name => $options) {
         $formatter_instance = $this->getFormatter($options);
         $settings_form = $formatter_instance->settingsForm($form, $form_state);
         if (!empty($settings_form)) {
             $elements['formatters']['settings'][$name] = array('#type' => 'fieldset', '#title' => $options['label'], '#parents' => array_merge($parents, array($name, 'settings')), '#weight' => $options['weight'], '#group' => 'formatter_settings');
             $elements['formatters']['settings'][$name] += $settings_form;
         }
         $elements['formatters']['settings'][$name]['formatter'] = array('#type' => 'value', '#value' => $name, '#parents' => array_merge($parents, array($name, 'formatter')));
     }
     return $elements;
 }
开发者ID:DrupalTV,项目名称:DrupalTV,代码行数:35,代码来源:FallbackFormatter.php

示例6: __construct

 /**
  * Constructs an AddressDefaultFormatter object.
  *
  * @param string $plugin_id
  *   The plugin_id for the formatter.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The definition of the field to which the formatter is associated.
  * @param array $settings
  *   The formatter settings.
  * @param string $label
  *   The formatter label display setting.
  * @param string $view_mode
  *   The view mode.
  * @param array $third_party_settings
  *   Any third party settings.
  * @param \CommerceGuys\Addressing\Repository\AddressFormatRepositoryInterface $address_format_repository
  *   The address format repository.
  * @param \CommerceGuys\Addressing\Repository\CountryRepositoryInterface $country_repository
  *   The country repository.
  * @param \CommerceGuys\Addressing\Repository\SubdivisionRepositoryInterface $subdivision_repository
  *   The subdivision repository.
  */
 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, AddressFormatRepositoryInterface $address_format_repository, CountryRepositoryInterface $country_repository, SubdivisionRepositoryInterface $subdivision_repository)
 {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->addressFormatRepository = $address_format_repository;
     $this->countryRepository = $country_repository;
     $this->subdivisionRepository = $subdivision_repository;
 }
开发者ID:seongbae,项目名称:drumo-distribution,代码行数:31,代码来源:AddressDefaultFormatter.php

示例7: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $enabled_plugins = array();
     $i = 0;
     foreach ($this->getSetting('provider_plugins') as $plugin_id => $plugin) {
         if ($plugin['checked']) {
             $plugin['weight'] = intval($i++);
             $enabled_plugins[$plugin_id] = $plugin;
         }
     }
     $elements['geocoder_plugins_title'] = array('#type' => 'item', '#weight' => 15, '#title' => t('Geocoder plugin(s)'), '#description' => t('Select the Geocoder plugins to use, you can reorder them. The first one to return a valid value will be used.'));
     $elements['provider_plugins'] = array('#type' => 'table', '#weight' => 20, '#header' => array(array('data' => $this->t('Enabled')), array('data' => $this->t('Weight')), array('data' => $this->t('Name'))), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'provider_plugins-order-weight')));
     $rows = array();
     $count = count($enabled_plugins);
     foreach (Geocoder::getPlugins('Provider') as $plugin_id => $plugin_name) {
         if (isset($enabled_plugins[$plugin_id])) {
             $weight = $enabled_plugins[$plugin_id]['weight'];
         } else {
             $weight = $count++;
         }
         $rows[$plugin_id] = array('#attributes' => array('class' => array('draggable')), '#weight' => $weight, 'checked' => array('#type' => 'checkbox', '#default_value' => isset($enabled_plugins[$plugin_id]) ? 1 : 0), 'weight' => array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $plugin_id)), '#title_display' => 'invisible', '#default_value' => $weight, '#attributes' => array('class' => array('provider_plugins-order-weight'))), 'name' => array('#plain_text' => $plugin_name));
     }
     uasort($rows, function ($a, $b) {
         return strcmp($a['#weight'], $b['#weight']);
     });
     foreach ($rows as $plugin_id => $row) {
         $elements['provider_plugins'][$plugin_id] = $row;
     }
     $elements['dumper_plugin'] = array('#type' => 'select', '#weight' => 25, '#title' => 'Output format', '#default_value' => $this->getSetting('dumper_plugin'), '#options' => Geocoder::getPlugins('dumper'), '#description' => t('Set the output format of the value. Ex, for a geofield, the format must be set to WKT.'));
     return $elements;
 }
开发者ID:seongbae,项目名称:drumo-distribution,代码行数:35,代码来源:GeocodeFormatterBase.php

示例8: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $elements['image_style'] = array('#type' => 'select', '#title' => t('Image style'), '#options' => image_style_options(FALSE), '#default_value' => $this->getSetting('image_style'), '#empty_option' => t('None (original image)'));
     $link_types = array('content' => t('Content'), 'youtube' => t('YouTube'));
     $elements['image_link'] = array('#title' => t('Link image to'), '#type' => 'select', '#default_value' => $this->getSetting('image_link'), '#empty_option' => t('Nothing'), '#options' => $link_types);
     return $elements;
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:11,代码来源:YouTubeThumbFormatter.php

示例9: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $elements = parent::settingsForm($form, $form_state);
     $options = \Drupal::service('geophp.geophp')->getAdapterMap();
     unset($options['google_geocode']);
     $elements['output_format'] = array('#title' => t('Output Format'), '#type' => 'select', '#default_value' => $this->getSetting('output_format'), '#options' => $options, '#required' => TRUE);
     return $elements;
 }
开发者ID:seongbae,项目名称:drumo-distribution,代码行数:11,代码来源:GeofieldDefaultFormatter.php

示例10: settingsSummary

 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = parent::settingsSummary();
     $format = $this->getSetting('flag_display');
     $formats = $this->getOutputFormats();
     $summary[] = $formats[$format];
     return $summary;
 }
开发者ID:globalbility,项目名称:flags,代码行数:11,代码来源:CountryFlagFormatter.php

示例11: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $form['show_quantity'] = ['#type' => 'checkbox', '#title' => t('Display a quantity input field on the add to cart form.'), '#default_value' => $this->getSetting('show_quantity')];
     $form['default_quantity'] = ['#type' => 'number', '#title' => t('Default quantity'), '#default_value' => $this->getSetting('default_quantity'), '#min' => 1, '#max' => 9999];
     $form['combine'] = ['#type' => 'checkbox', '#title' => t('Attempt to combine line items containing the same product variation.'), '#description' => t('The line item type, referenced product variation, and data from fields exposed on the Add to Cart form must all match to combine.'), '#default_value' => $this->getSetting('combine')];
     return $form;
 }
开发者ID:marmouset,项目名称:drupal,代码行数:11,代码来源:AddToCartFormatter.php

示例12: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::settingsForm($form, $form_state);
     $field_settings = $this->getFieldSettings();
     $settings = $this->getSettings();
     $form['show_interest_groups'] = array('#title' => t('Show Interest Groups'), '#type' => 'checkbox', '#description' => $field_settings['show_interest_groups'] ? t('Check to display interest group membership details.') : t('To display Interest Groups, first enable them in the field instance settings.'), '#default_value' => $field_settings['show_interest_groups'] && $settings['show_interest_groups'], '#disabled' => !$field_settings['show_interest_groups']);
     return $form;
 }
开发者ID:rafavergara,项目名称:ddv8,代码行数:11,代码来源:MailchimpListsSubscribeDefaultFormatter.php

示例13: __construct

 /**
  * Constructs a new instance.
  *
  * @param string $plugin_id
  *   The plugin_id for the formatter.
  * @param mixed $plugin_definition
  *   The plugin implementation definition.
  * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  *   The definition of the field to which the formatter is associated.
  * @param array $settings
  *   The formatter settings.
  * @param string $label
  *   The formatter label display setting.
  * @param string $view_mode
  *   The view mode.
  * @param array $third_party_settings
  *   Any third party settings.
  */
 public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, RequestStack $request_stack, EntityFormBuilderInterface $entity_form_builder, EntityStorageInterface $payment_storage, PaymentLineItemManagerInterface $payment_line_item_manager)
 {
     parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
     $this->entityFormBuilder = $entity_form_builder;
     $this->paymentLineItemManager = $payment_line_item_manager;
     $this->paymentStorage = $payment_storage;
     $this->requestStack = $request_stack;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:26,代码来源:PaymentForm.php

示例14: settingsSummary

 /**
  * {@inheritdoc}
  */
 public function settingsSummary()
 {
     $summary = parent::settingsSummary();
     if ($override = $this->getSetting('timezone_override')) {
         $summary[] = $this->t('Time zone: @timezone', array('@timezone' => $override));
     }
     return $summary;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:11,代码来源:DateTimeFormatterBase.php

示例15: defaultSettings

 /**
  * {@inheritdoc}
  */
 public static function defaultSettings()
 {
     $settings = [];
     foreach (['first', 'second'] as $subfield) {
         $settings[$subfield] = ['hidden' => FALSE, 'prefix' => '', 'suffix' => ''];
     }
     return $settings + parent::defaultSettings();
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:11,代码来源:Base.php


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