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


PHP FieldItemBase::storageSettingsForm方法代码示例

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


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

示例1: storageSettingsForm

 /**
  * {@inheritdoc}
  */
 public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data)
 {
     $element = parent::storageSettingsForm($form, $form_state, $has_data);
     $lists = mailchimp_get_lists();
     $options = array('' => t('-- Select --'));
     foreach ($lists as $mc_list) {
         $options[$mc_list['id']] = $mc_list['name'];
     }
     $field_map = \Drupal::entityManager()->getFieldMap();
     $field_definitions = array();
     foreach ($field_map as $entity_type => $fields) {
         $field_definitions[$entity_type] = \Drupal::entityManager()->getFieldStorageDefinitions($entity_type);
     }
     // Prevent MailChimp lists that have already been assigned to a field
     // appearing as field options.
     foreach ($field_map as $entity_type => $fields) {
         foreach ($fields as $field_name => $field_properties) {
             if ($field_properties['type'] == 'mailchimp_lists_subscription') {
                 /* @var $field \Drupal\field\Entity\FieldStorageConfig */
                 $field = $field_definitions[$entity_type][$field_name];
                 $field_settings = $field->getSettings();
                 if ($field_name != $this->getFieldDefinition()->getName() && isset($field_settings['mc_list_id'])) {
                     unset($options[$field_settings['mc_list_id']]);
                 }
             }
         }
     }
     $refresh_lists_url = Url::fromRoute('mailchimp_lists.refresh');
     $mailchimp_url = Url::fromUri('https://admin.mailchimp.com', array('attributes' => array('target' => '_blank')));
     $element['mc_list_id'] = array('#type' => 'select', '#title' => t('MailChimp List'), '#multiple' => FALSE, '#description' => t('Available MailChimp lists which are not already
     attached to Mailchimp Subscription Fields. If there are no options,
     make sure you have created a list at !MailChimp first, then !cacheclear.', array('!MailChimp' => \Drupal::l('MailChimp', $mailchimp_url), '!cacheclear' => \Drupal::l('clear your list cache', $refresh_lists_url))), '#options' => $options, '#default_value' => $this->getSetting('mc_list_id'), '#required' => TRUE, '#disabled' => $has_data);
     $element['double_opt_in'] = array('#type' => 'checkbox', '#title' => 'Require subscribers to Double Opt-in', '#description' => 'New subscribers will be sent a link with an email they must follow to confirm their subscription.', '#default_value' => $this->getSetting('double_opt_in'), '#disabled' => $has_data);
     $element['send_welcome'] = array('#type' => 'checkbox', '#title' => 'Send a welcome email to new subscribers', '#description' => 'New subscribers will be sent a welcome email once they are confirmed.', '#default_value' => $this->getSetting('send_welcome'), '#disabled' => $has_data);
     return $element;
 }
开发者ID:rafavergara,项目名称:ddv8,代码行数:39,代码来源:MailchimpListsSubscription.php


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