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


PHP CommentType::loadMultiple方法代码示例

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


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

示例1: storageSettingsForm

 /**
  * {@inheritdoc}
  */
 public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data)
 {
     $element = array();
     // @todo Inject entity storage once typed-data supports container injection.
     //   See https://www.drupal.org/node/2053415 for more details.
     $comment_types = CommentType::loadMultiple();
     $options = array();
     $entity_type = $this->getEntity()->getEntityTypeId();
     foreach ($comment_types as $comment_type) {
         if ($comment_type->getTargetEntityTypeId() == $entity_type) {
             $options[$comment_type->id()] = $comment_type->label();
         }
     }
     $element['comment_type'] = array('#type' => 'select', '#title' => t('Comment type'), '#options' => $options, '#required' => TRUE, '#description' => $this->t('Select the Comment type to use for this comment field. Manage the comment types from the <a href="@url">administration overview page</a>.', array('@url' => $this->url('entity.comment_type.collection'))), '#default_value' => $this->getSetting('comment_type'), '#disabled' => $has_data);
     return $element;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:19,代码来源:CommentItem.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Honeypot Configuration.
     $form['configuration'] = ['#type' => 'fieldset', '#title' => t('Honeypot Configuration'), '#collapsible' => TRUE, '#collapsed' => FALSE];
     $form['configuration']['protect_all_forms'] = ['#type' => 'checkbox', '#title' => t('Protect all forms with Honeypot'), '#description' => t('Enable Honeypot protection for ALL forms on this site (it is best to only enable Honeypot for the forms you need below).'), '#default_value' => $this->config('honeypot.settings')->get('protect_all_forms')];
     $form['configuration']['protect_all_forms']['#description'] .= '<br />' . t('<strong>Page caching will be disabled on any page where a form is present if the Honeypot time limit is not set to 0.</strong>');
     $form['configuration']['log'] = ['#type' => 'checkbox', '#title' => t('Log blocked form submissions'), '#description' => t('Log submissions that are blocked due to Honeypot protection.'), '#default_value' => $this->config('honeypot.settings')->get('log')];
     $form['configuration']['element_name'] = ['#type' => 'textfield', '#title' => t('Honeypot element name'), '#description' => t("The name of the Honeypot form field. It's usually most effective to use a generic name like email, homepage, or link, but this should be changed if it interferes with fields that are already in your forms. Must not contain spaces or special characters."), '#default_value' => $this->config('honeypot.settings')->get('element_name'), '#required' => TRUE, '#size' => 30];
     $form['configuration']['time_limit'] = ['#type' => 'textfield', '#title' => t('Honeypot time limit'), '#description' => t('Minimum time required before form should be considered entered by a human instead of a bot. Set to 0 to disable.'), '#default_value' => $this->config('honeypot.settings')->get('time_limit'), '#required' => TRUE, '#size' => 5, '#field_suffix' => t('seconds')];
     $form['configuration']['time_limit']['#description'] .= '<br />' . t('<strong>Page caching will be disabled if there is a form protected by time limit on the page.</strong>');
     // Honeypot Enabled forms.
     $form_settings = $this->config('honeypot.settings')->get('form_settings');
     $form['form_settings'] = ['#type' => 'fieldset', '#title' => t('Honeypot Enabled Forms'), '#description' => t("Check the boxes next to individual forms on which you'd like Honeypot protection enabled."), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE, '#states' => ['invisible' => ['input[name="protect_all_forms"]' => ['checked' => TRUE]]]];
     // Generic forms.
     $form['form_settings']['general_forms'] = ['#markup' => '<h5>' . t('General Forms') . '</h5>'];
     // User register form.
     $form['form_settings']['user_register_form'] = ['#type' => 'checkbox', '#title' => t('User Registration form'), '#default_value' => $this->getFormSettingsValue($form_settings, 'user_register_form')];
     // User password form.
     $form['form_settings']['user_pass'] = ['#type' => 'checkbox', '#title' => t('User Password Reset form'), '#default_value' => $this->getFormSettingsValue($form_settings, 'user_pass')];
     // If webform.module enabled, add webforms.
     // TODO D8 - See if D8 version of Webform.module still uses this form ID.
     if (\Drupal::moduleHandler()->moduleExists('webform')) {
         $form['form_settings']['webforms'] = ['#type' => 'checkbox', '#title' => t('Webforms (all)'), '#default_value' => $this->getFormSettingsValue($form_settings, 'webforms')];
     }
     // If contact.module enabled, add contact forms.
     if (\Drupal::moduleHandler()->moduleExists('contact')) {
         $form['form_settings']['contact_forms'] = ['#markup' => '<h5>' . t('Contact Forms') . '</h5>'];
         $bundles = \Drupal::entityManager()->getBundleInfo('contact_message');
         $formController = \Drupal::entityManager()->getFormObject('contact_message', 'default');
         foreach ($bundles as $bundle_key => $bundle) {
             $stub = entity_create('contact_message', ['contact_form' => $bundle_key]);
             $formController->setEntity($stub);
             $form_id = $formController->getFormId();
             $form['form_settings'][$form_id] = ['#type' => 'checkbox', '#title' => SafeMarkup::checkPlain($bundle['label']), '#default_value' => $this->getFormSettingsValue($form_settings, $form_id)];
         }
     }
     // Node types for node forms.
     if (\Drupal::moduleHandler()->moduleExists('node')) {
         $types = NodeType::loadMultiple();
         if (!empty($types)) {
             // Node forms.
             $form['form_settings']['node_forms'] = ['#markup' => '<h5>' . t('Node Forms') . '</h5>'];
             foreach ($types as $type) {
                 $id = $type->getEntityTypeId() . '_node_form';
                 $form['form_settings'][$id] = ['#type' => 'checkbox', '#title' => t('@name node form', ['@name' => $type->label()]), '#default_value' => $this->getFormSettingsValue($form_settings, $id)];
             }
         }
     }
     // Comment types for comment forms.
     if (\Drupal::moduleHandler()->moduleExists('comment')) {
         $types = CommentType::loadMultiple();
         if (!empty($types)) {
             $form['form_settings']['comment_forms'] = ['#markup' => '<h5>' . t('Comment Forms') . '</h5>'];
             foreach ($types as $type) {
                 $id = 'comment_' . $type->id() . '_form';
                 $form['form_settings'][$id] = ['#type' => 'checkbox', '#title' => t('@name comment form', ['@name' => $type->label()]), '#default_value' => $this->getFormSettingsValue($form_settings, $id)];
             }
         }
     }
     // Store the keys we want to save in configuration when form is submitted.
     $keys_to_save = array_keys($form['configuration']);
     foreach ($keys_to_save as $key => $key_to_save) {
         if (strpos($key_to_save, '#') !== FALSE) {
             unset($keys_to_save[$key]);
         }
     }
     $form_state->setStorage(['keys' => $keys_to_save]);
     // For now, manually add submit button. Hopefully, by the time D8 is
     // released, there will be something like system_settings_form() in D7.
     $form['actions']['#type'] = 'container';
     $form['actions']['submit'] = ['#type' => 'submit', '#value' => t('Save configuration')];
     return $form;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:76,代码来源:HoneypotSettingsController.php

示例3: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array &$form, FormStateInterface $form_state, $has_data)
 {
     $element = array();
     // @todo Inject entity storage once typed-data supports container injection.
     // See https://drupal.org/node/2053415 for more details.
     $comment_types = CommentType::loadMultiple();
     $options = array();
     $entity_type = $this->getEntity()->getEntityTypeId();
     foreach ($comment_types as $comment_type) {
         if ($comment_type->getTargetEntityTypeId() == $entity_type) {
             $options[$comment_type->id()] = $comment_type->label();
         }
     }
     $element['comment_type'] = array('#type' => 'select', '#title' => t('Comment type'), '#options' => $options, '#description' => t('Select the Comment type to use for this comment field.'), '#default_value' => $this->getSetting('comment_type'), '#disabled' => $has_data);
     return $element;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:19,代码来源:CommentItem.php


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