Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     /** @var \Drupal\rng\EventTypeInterface $event_type */
     $event_type = $this->entity;
     if (!$event_type->isNew()) {
         $form['#title'] = $this->t('Edit event type %label configuration', array('%label' => $event_type->label()));
     }
     if ($event_type->isNew()) {
         $bundle_options = [];
         // Generate a list of fieldable bundles which are not events.
         foreach ($this->entityManager->getDefinitions() as $entity_type) {
             if ($entity_type->isSubclassOf('\\Drupal\\Core\\Entity\\ContentEntityInterface')) {
                 foreach ($this->entityManager->getBundleInfo($entity_type->id()) as $bundle => $bundle_info) {
                     if (!$this->eventManager->eventType($entity_type->id(), $bundle)) {
                         $bundle_options[(string) $entity_type->getLabel()][$entity_type->id() . '.' . $bundle] = $bundle_info['label'];
                     }
                 }
             }
         }
         if ($this->moduleHandler->moduleExists('node')) {
             $form['#attached']['library'][] = 'rng/rng.admin';
             $form['entity_type'] = ['#type' => 'radios', '#options' => NULL, '#title' => $this->t('Event entity type'), '#required' => TRUE];
             $form['entity_type']['node']['radio'] = ['#type' => 'radio', '#title' => $this->t('Create a new content type'), '#description' => $this->t('Create a content type to use as an event type.'), '#return_value' => "node", '#parents' => array('entity_type'), '#default_value' => 'node'];
             $form['entity_type']['existing']['radio'] = ['#type' => 'radio', '#title' => $this->t('Use existing bundle'), '#description' => $this->t('Use an existing entity/bundle combination.'), '#return_value' => "existing", '#parents' => array('entity_type'), '#default_value' => ''];
             $form['entity_type']['existing']['container'] = ['#type' => 'container', '#attributes' => ['class' => ['rng-radio-indent']]];
         }
         $form['entity_type']['existing']['container']['bundle'] = array('#type' => 'select', '#title' => $this->t('Bundle'), '#options' => $bundle_options, '#default_value' => $event_type->id(), '#disabled' => !$event_type->isNew(), '#empty_option' => $bundle_options ? NULL : t('No Bundles Available'));
     }
     $form['settings'] = array('#type' => 'fieldset', '#title' => $this->t('Settings'));
     // Mirror permission.
     $form['access']['mirror_update'] = array('#group' => 'settings', '#type' => 'checkbox', '#title' => t('Mirror manage registrations with update permission'), '#description' => t('Allow users to <strong>manage registrations</strong> if they have <strong>update</strong> permission on an event entity.'), '#default_value' => (bool) ($event_type->getEventManageOperation() !== NULL ? $event_type->getEventManageOperation() : TRUE));
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function setMapperDefinition($mapper_definition)
 {
     $this->baseEntityType = $mapper_definition['base_entity_type'];
     $this->baseEntityInfo = $this->entityManager->getDefinition($this->baseEntityType);
     $this->baseEntityBundles = $this->entityManager->getBundleInfo($this->baseEntityType);
     return $this;
 }
 /**
  * Returns an array of content translation permissions.
  *
  * @return array
  */
 public function contentPermissions()
 {
     $permission = [];
     // Create a translate permission for each enabled entity type and (optionally)
     // bundle.
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($permission_granularity = $entity_type->getPermissionGranularity()) {
             $t_args = ['@entity_label' => $entity_type->getLowercaseLabel()];
             switch ($permission_granularity) {
                 case 'bundle':
                     foreach ($this->entityManager->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
                         if ($this->contentTranslationManager->isEnabled($entity_type_id, $bundle)) {
                             $t_args['%bundle_label'] = isset($bundle_info['label']) ? $bundle_info['label'] : $bundle;
                             $permission["translate {$bundle} {$entity_type_id}"] = ['title' => $this->t('Translate %bundle_label @entity_label', $t_args)];
                         }
                     }
                     break;
                 case 'entity_type':
                     if ($this->contentTranslationManager->isEnabled($entity_type_id)) {
                         $permission["translate {$entity_type_id}"] = ['title' => $this->t('Translate @entity_label', $t_args)];
                     }
                     break;
             }
         }
     }
     return $permission;
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $entity_type_id = $this->configuration['target_type'];
     $selection_handler_settings = $this->configuration['handler_settings'];
     $entity_type = $this->entityManager->getDefinition($entity_type_id);
     $bundles = $this->entityManager->getBundleInfo($entity_type_id);
     // Merge-in default values.
     $selection_handler_settings += array('target_bundles' => NULL, 'sort' => array('field' => '_none'), 'auto_create' => FALSE, 'auto_create_bundle' => NULL);
     if ($entity_type->hasKey('bundle')) {
         $bundle_options = array();
         foreach ($bundles as $bundle_name => $bundle_info) {
             $bundle_options[$bundle_name] = $bundle_info['label'];
         }
         natsort($bundle_options);
         $form['target_bundles'] = array('#type' => 'checkboxes', '#title' => $this->t('Bundles'), '#options' => $bundle_options, '#default_value' => (array) $selection_handler_settings['target_bundles'], '#required' => TRUE, '#size' => 6, '#multiple' => TRUE, '#element_validate' => [[get_class($this), 'elementValidateFilter']], '#ajax' => TRUE, '#limit_validation_errors' => []);
         $form['target_bundles_update'] = ['#type' => 'submit', '#value' => $this->t('Update form'), '#limit_validation_errors' => [], '#attributes' => ['class' => ['js-hide']], '#submit' => [[EntityReferenceItem::class, 'settingsAjaxSubmit']]];
     } else {
         $form['target_bundles'] = array('#type' => 'value', '#value' => array());
     }
     if ($entity_type->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
         $fields = array();
         foreach (array_keys($bundles) as $bundle) {
             $bundle_fields = array_filter($this->entityManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) {
                 return !$field_definition->isComputed();
             });
             foreach ($bundle_fields as $field_name => $field_definition) {
                 /* @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
                 $columns = $field_definition->getFieldStorageDefinition()->getColumns();
                 // If there is more than one column, display them all, otherwise just
                 // display the field label.
                 // @todo: Use property labels instead of the column name.
                 if (count($columns) > 1) {
                     foreach ($columns as $column_name => $column_info) {
                         $fields[$field_name . '.' . $column_name] = $this->t('@label (@column)', array('@label' => $field_definition->getLabel(), '@column' => $column_name));
                     }
                 } else {
                     $fields[$field_name] = $this->t('@label', array('@label' => $field_definition->getLabel()));
                 }
             }
         }
         $form['sort']['field'] = array('#type' => 'select', '#title' => $this->t('Sort by'), '#options' => array('_none' => $this->t('- None -')) + $fields, '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $selection_handler_settings['sort']['field']);
         $form['sort']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entity_reference-settings')), '#process' => [[EntityReferenceItem::class, 'formProcessMergeParent']]);
         if ($selection_handler_settings['sort']['field'] != '_none') {
             // Merge-in default values.
             $selection_handler_settings['sort'] += array('direction' => 'ASC');
             $form['sort']['settings']['direction'] = array('#type' => 'select', '#title' => $this->t('Sort direction'), '#required' => TRUE, '#options' => array('ASC' => $this->t('Ascending'), 'DESC' => $this->t('Descending')), '#default_value' => $selection_handler_settings['sort']['direction']);
         }
     }
     $form['auto_create'] = array('#type' => 'checkbox', '#title' => $this->t("Create referenced entities if they don't already exist"), '#default_value' => $selection_handler_settings['auto_create'], '#weight' => -2);
     if ($entity_type->hasKey('bundle')) {
         $bundles = array_intersect_key($bundle_options, array_filter((array) $selection_handler_settings['target_bundles']));
         $form['auto_create_bundle'] = ['#type' => 'select', '#title' => $this->t('Store new items in'), '#options' => $bundles, '#default_value' => $selection_handler_settings['auto_create_bundle'], '#access' => count($bundles) > 1, '#states' => ['visible' => [':input[name="settings[handler_settings][auto_create]"]' => ['checked' => TRUE]]], '#weight' => -1];
     }
     return $form;
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $field_storage = $this->entity->getFieldStorageDefinition();
     $bundles = $this->entityManager->getBundleInfo($this->entity->getTargetEntityTypeId());
     $bundle_label = $bundles[$this->entity->getTargetBundle()]['label'];
     if ($field_storage && !$field_storage->isLocked()) {
         $this->entity->delete();
         drupal_set_message($this->t('The field %field has been deleted from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label)));
     } else {
         drupal_set_message($this->t('There was a problem removing the %field from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label)), 'error');
     }
     $form_state->setRedirectUrl($this->getCancelUrl());
     // Fields are purged on cron. However field module prevents disabling modules
     // when field types they provided are used in a field until it is fully
     // purged. In the case that a field has minimal or no content, a single call
     // to field_purge_batch() will remove it from the system. Call this with a
     // low batch limit to avoid administrators having to wait for cron runs when
     // removing fields that meet this criteria.
     field_purge_batch(10);
 }
 /**
  * Gets the target bundles for the current field.
  *
  * @return string[]
  *   A list of bundles.
  */
 protected function getTargetBundles()
 {
     $settings = $this->getFieldSettings();
     if (!empty($settings['handler_settings']['target_bundles'])) {
         $target_bundles = array_values($settings['handler_settings']['target_bundles']);
     } else {
         // If no target bundles have been specified then all are available.
         $target_bundles = array_keys($this->entityManager->getBundleInfo($settings['target_type']));
     }
     return $target_bundles;
 }
Ejemplo n.º 7
0
 /**
  * Provides a list of bundle options for use in select lists.
  *
  * @return array
  *   A keyed array of bundle => label.
  */
 protected function bundleOptions()
 {
     $options = [];
     foreach ($this->entityManager->getBundleInfo($this->entityType()) as $bundle => $info) {
         if (!empty($info['label'])) {
             $options[$bundle] = $info['label'];
         } else {
             $options[$bundle] = $bundle;
         }
     }
     return $options;
 }
Ejemplo n.º 8
0
  /**
   * Builds the group string used in the match array.
   *
   * @param \Drupal\Core\Entity\EntityInterface $entity
   *   The matched entity.
   *
   * @return string
   *   The match group for this entity.
   */
  protected function buildGroup($entity) {
    $group = $entity->getEntityType()->getLabel();

    // If the entities by this entity should be grouped by bundle, get the
    // name and append it to the group.
    if ($this->configuration['group_by_bundle']) {
      $bundles = $this->entityManager->getBundleInfo($entity->getEntityTypeId());
      $bundle_label = $bundles[$entity->bundle()]['label'];
      $group .= ' - ' . $bundle_label;
    }

    return $group;
  }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $entity_type_id = $this->definition['entity_type'];
     // Derivative IDs are all entity:entity_type. Sanitized for js.
     // The ID is converted back on submission.
     $sanitized_id = ArgumentPluginBase::encodeValidatorId($this->definition['id']);
     $entity_type = $this->entityManager->getDefinition($entity_type_id);
     // If the entity has bundles, allow option to restrict to bundle(s).
     if ($entity_type->hasKey('bundle')) {
         $bundle_options = array();
         foreach ($this->entityManager->getBundleInfo($entity_type_id) as $bundle_id => $bundle_info) {
             $bundle_options[$bundle_id] = $bundle_info['label'];
         }
         $form['bundles'] = array('#title' => $entity_type->getBundleLabel() ?: $this->t('Bundles'), '#default_value' => $this->options['bundles'], '#type' => 'checkboxes', '#options' => $bundle_options, '#description' => $this->t('If none are selected, all are allowed.'));
     }
     // Offer the option to filter by access to the entity in the argument.
     $form['access'] = array('#type' => 'checkbox', '#title' => $this->t('Validate user has access to the %name', array('%name' => $entity_type->getLabel())), '#default_value' => $this->options['access']);
     $form['operation'] = array('#type' => 'radios', '#title' => $this->t('Access operation to check'), '#options' => array('view' => $this->t('View'), 'update' => $this->t('Edit'), 'delete' => $this->t('Delete')), '#default_value' => $this->options['operation'], '#states' => array('visible' => array(':input[name="options[validate][options][' . $sanitized_id . '][access]"]' => array('checked' => TRUE))));
     // If class is multiple capable give the option to validate single/multiple.
     if ($this->multipleCapable) {
         $form['multiple'] = array('#type' => 'radios', '#title' => $this->t('Multiple arguments'), '#options' => array(0 => $this->t('Single ID', array('%type' => $entity_type->getLabel())), 1 => $this->t('One or more IDs separated by , or +', array('%type' => $entity_type->getLabel()))), '#default_value' => (string) $this->options['multiple']);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function isEnabled($entity_type_id, $bundle = NULL)
 {
     $enabled = FALSE;
     if ($this->isSupported($entity_type_id)) {
         $bundles = !empty($bundle) ? array($bundle) : array_keys($this->entityManager->getBundleInfo($entity_type_id));
         foreach ($bundles as $bundle) {
             $config = $this->loadContentLanguageSettings($entity_type_id, $bundle);
             if ($config->getThirdPartySetting('content_translation', 'enabled', FALSE)) {
                 $enabled = TRUE;
                 break;
             }
         }
     }
     return $enabled;
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $entity_type_id = $this->configuration['target_type'];
     $selection_handler_settings = $this->configuration['handler_settings'];
     $entity_type = $this->entityManager->getDefinition($entity_type_id);
     $bundles = $this->entityManager->getBundleInfo($entity_type_id);
     // Merge-in default values.
     $selection_handler_settings += array('target_bundles' => array(), 'sort' => array('field' => '_none'), 'auto_create' => FALSE);
     if ($entity_type->hasKey('bundle')) {
         $bundle_options = array();
         foreach ($bundles as $bundle_name => $bundle_info) {
             $bundle_options[$bundle_name] = $bundle_info['label'];
         }
         $form['target_bundles'] = array('#type' => 'checkboxes', '#title' => $this->t('Bundles'), '#options' => $bundle_options, '#default_value' => !empty($selection_handler_settings['target_bundles']) ? $selection_handler_settings['target_bundles'] : array(), '#required' => TRUE, '#size' => 6, '#multiple' => TRUE, '#element_validate' => array('_entity_reference_element_validate_filter'));
     } else {
         $form['target_bundles'] = array('#type' => 'value', '#value' => array());
     }
     if ($entity_type->isSubclassOf('\\Drupal\\Core\\Entity\\FieldableEntityInterface')) {
         $fields = array();
         foreach (array_keys($bundles) as $bundle) {
             $bundle_fields = array_filter($this->entityManager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) {
                 return !$field_definition->isComputed();
             });
             foreach ($bundle_fields as $field_name => $field_definition) {
                 /* @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
                 $columns = $field_definition->getFieldStorageDefinition()->getColumns();
                 // If there is more than one column, display them all, otherwise just
                 // display the field label.
                 // @todo: Use property labels instead of the column name.
                 if (count($columns) > 1) {
                     foreach ($columns as $column_name => $column_info) {
                         $fields[$field_name . '.' . $column_name] = $this->t('@label (@column)', array('@label' => $field_definition->getLabel(), '@column' => $column_name));
                     }
                 } else {
                     $fields[$field_name] = $this->t('@label', array('@label' => $field_definition->getLabel()));
                 }
             }
         }
         $form['sort']['field'] = array('#type' => 'select', '#title' => $this->t('Sort by'), '#options' => array('_none' => $this->t('- None -')) + $fields, '#ajax' => TRUE, '#limit_validation_errors' => array(), '#default_value' => $selection_handler_settings['sort']['field']);
         $form['sort']['settings'] = array('#type' => 'container', '#attributes' => array('class' => array('entity_reference-settings')), '#process' => array('_entity_reference_form_process_merge_parent'));
         if ($selection_handler_settings['sort']['field'] != '_none') {
             // Merge-in default values.
             $selection_handler_settings['sort'] += array('direction' => 'ASC');
             $form['sort']['settings']['direction'] = array('#type' => 'select', '#title' => $this->t('Sort direction'), '#required' => TRUE, '#options' => array('ASC' => $this->t('Ascending'), 'DESC' => $this->t('Descending')), '#default_value' => $selection_handler_settings['sort']['direction']);
         }
     }
     return $form;
 }
Ejemplo n.º 12
0
 /**
  * Writes the cache of relation links.
  *
  * @param array $context
  *   Context from the normalizer/serializer operation.
  */
 protected function writeCache($context = array())
 {
     $data = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type) {
         if ($entity_type instanceof ContentEntityTypeInterface) {
             foreach ($this->entityManager->getBundleInfo($entity_type->id()) as $bundle => $bundle_info) {
                 foreach ($this->entityManager->getFieldDefinitions($entity_type->id(), $bundle) as $field_definition) {
                     $relation_uri = $this->getRelationUri($entity_type->id(), $bundle, $field_definition->getName(), $context);
                     $data[$relation_uri] = array('entity_type' => $entity_type, 'bundle' => $bundle, 'field_name' => $field_definition->getName());
                 }
             }
         }
     }
     // These URIs only change when field info changes, so cache it permanently
     // and only clear it when the fields cache is cleared.
     $this->cache->set('rest:links:relations', $data, Cache::PERMANENT, array('entity_field_info'));
 }
Ejemplo n.º 13
0
 /**
  * Helper method to fetch the field map for an entity type.
  *
  * @param EntityTypeInterface $entity_type
  */
 public function getFieldMap(EntityTypeInterface $entity_type)
 {
     $map = array();
     $bundle_info = $this->entityManager->getBundleInfo($entity_type->id());
     foreach ($bundle_info as $bundle_id => $bundle_label) {
         $definitions = $this->entityManager->getFieldDefinitions($entity_type->id(), $bundle_id);
         foreach ($definitions as $definition) {
             $name = $definition->getName();
             // We don't want our own fields to be part of the migration mapping or
             // they would get assigned NULL instead of default values.
             if (!in_array($name, ['workspace', '_deleted', '_rev'])) {
                 $map[$name] = $name;
             }
         }
     }
     return $map;
 }
Ejemplo n.º 14
0
 /**
  * {@inheritdoc}
  */
 public function getBundleInfo($entity_type)
 {
     return $this->entityManager->getBundleInfo($entity_type);
 }
 /**
  * Returns bundles.
  *
  * @return string[]
  *   An array of bundle labels, keyed by bundle.
  */
 protected function getBundles()
 {
     return array_map(function ($bundle_info) {
         return $bundle_info['label'];
     }, $this->entityManager->getBundleInfo($this->getEntityTypeId()));
 }
Ejemplo n.º 16
0
 /**
  * Registers bundle information for the mock entity type.
  *
  * @param array $bundle_info
  *   The bundle information to register.
  */
 protected function registerBundleInfo($bundle_info)
 {
     $this->entityManager->getBundleInfo($this->entityTypeId)->willReturn([$this->entityTypeId => $bundle_info]);
 }
    /**
     * {@inheritdoc}
     */
    public function buildForm(array $form, FormStateInterface $form_state)
    {
        global $base_url;
        $my_path = drupal_get_path('module', 'sharethis');
        // First, setup variables we will need.
        // Get the path variables setup.
        // Load the css and js for our module's configuration.
        $config = $this->config('sharethis.settings');
        $current_options_array = $this->sharethisManager->getOptions();
        // Create the variables related to button choice.
        $button_choice = $current_options_array['buttons'];
        // Create the variables related to services chosen.
        $service_string = $current_options_array['services'];
        $service_string_markup = "";
        foreach (explode(",", $service_string) as $name => $string) {
            $key = explode(":", Unicode::substr($string, 0, -1));
            $key = $key[1];
            $service_string_markup[] = $key;
        }
        // Create the variables for publisher keys.
        $publisher = $current_options_array['publisherID'];
        // Create the variables for teasers.
        $form = array();
        $form['options'] = array('#type' => 'fieldset', '#title' => t('Display'));
        $form['options']['button_option'] = array('#required' => TRUE, '#type' => 'radios', '#options' => array('stbc_large' => t('Large Chicklets'), 'stbc_' => t('Small Chicklets'), 'stbc_button' => t('Classic Buttons'), 'stbc_vcount' => t('Vertical Counters'), 'stbc_hcount' => t('Horizontal Counters'), 'stbc_custom' => t('Custom Buttons via CSS')), '#default_value' => $button_choice, '#title' => t("Choose a button style:"), '#prefix' => '<div class="st_widgetContain"><div class="st_spriteCover"><img id="stb_sprite" class="st_buttonSelectSprite ' . $button_choice . '" src="' . $base_url . '/' . $my_path . '/img/preview_sprite.png" /></div><div class="st_widgetPic"><img class="st_buttonSelectImage" src="' . $base_url . '/' . $my_path . '/img/preview_bg.png" /></div>', '#suffix' => '</div>');
        $form['options']['service_option'] = array('#description' => t('<b>Add</b> a service by selecting it on the right and clicking the <i>left arrow</i>.  <b>Remove</b> it by clicking the <i>right arrow</i>.<br /><b>Change the order</b> of services under "Selected Services" by using the <i>up</i> and <i>down</i> arrows.'), '#required' => TRUE, '#type' => 'textfield', '#prefix' => '<div>', '#suffix' => '</div><div id="myPicker"></div>', '#title' => t("Choose Your Services."), '#default_value' => $service_string, '#maxlength' => 1024);
        $form['options']['option_extras'] = array('#title' => $this->t('Extra services'), '#description' => $this->t('Select additional services which will be available. These are not officially supported by ShareThis, but are available.'), '#type' => 'checkboxes', '#options' => ['Google Plus One:plusone' => $this->t('Google Plus One'), 'Facebook Like:fblike' => $this->t('Facebook Like')], '#default_value' => $config->get('option_extras'));
        $form['options']['callesi'] = array('#type' => 'hidden', '#default_value' => $current_options_array['callesi']);
        $form['additional_settings'] = array('#type' => 'vertical_tabs');
        $form['context'] = array('#type' => 'details', '#title' => t('Context'), '#group' => 'additional_settings', '#description' => t('Configure where the ShareThis widget should appear.'));
        $form['context']['location'] = array('#title' => t('Location'), '#type' => 'radios', '#options' => array('content' => t('Node content'), 'block' => t('Block'), 'links' => t('Links area')), '#default_value' => $config->get('location'));
        // Add an information section for each location type, each dependent on the
        // currently selected location.
        foreach (array('links', 'content', 'block') as $location_type) {
            $form['context'][$location_type]['#type'] = 'container';
            $form['context'][$location_type]['#states']['visible'][':input[name="location"]'] = array('value' => $location_type);
        }
        // Add help text for the 'content' location.
        $form['context']['content']['help'] = array('#markup' => t('When using the Content location, you must place the ShareThis links in the <a href="@url">Manage Display</a> section of each content type.'), '#weight' => 10, '#prefix' => '<em>', '#suffix' => '</em>');
        // Add help text for the 'block' location.
        $form['context']['block']['#children'] = 'You must choose which region to display the in from the Blocks administration';
        $entity_bundles = $this->entityManager->getBundleInfo('node');
        // Add checkboxes for each view mode of each bundle.
        $entity_modes = $this->entityManager->getViewModes('node');
        $modes = array();
        foreach ($entity_modes as $mode => $mode_info) {
            $modes[$mode] = $mode_info['label'];
        }
        // Get a list of content types and view modes.
        foreach ($entity_bundles as $bundle => $bundle_info) {
            $form['context']['links'][$bundle . '_options'] = array('#title' => t('%label View Modes', array('%label' => $bundle_info['label'])), '#description' => t('Select which view modes the ShareThis widget should appear on for %label nodes.', array('%label' => $bundle_info['label'])), '#type' => 'checkboxes', '#options' => $modes, '#default_value' => $config->get('sharethisnodes.' . $bundle));
        }
        // Allow the user to choose which content types will have ShareThis added
        // when using the 'Content' location.
        $content_types = array();
        $enabled_content_types = $current_options_array['node_types'];
        foreach ($entity_bundles as $bundle => $bundle_info) {
            $content_types[$bundle] = $this->t($bundle_info['label']);
        }
        $form['context']['content']['node_types'] = array('#title' => $this->t('Node Types'), '#description' => $this->t('Select which node types the ShareThis widget should appear on.'), '#type' => 'checkboxes', '#options' => $content_types, '#default_value' => $enabled_content_types);
        $form['context']['comments'] = array('#title' => $this->t('Comments'), '#type' => 'checkbox', '#default_value' => $config->get('comments'), '#description' => $this->t('Display ShareThis on comments.'), '#access' => $this->moduleHandler->moduleExists('comment'));
        $sharethis_weight_list = array(-100, -50, -25, -10, 0, 10, 25, 50, 100);
        $form['context']['weight'] = array('#title' => $this->t('Weight'), '#description' => $this->t('The weight of the widget determines the location on the page where it will appear.'), '#required' => FALSE, '#type' => 'select', '#options' => array_combine($sharethis_weight_list, $sharethis_weight_list), '#default_value' => $config->get('weight'));
        $form['advanced'] = array('#type' => 'details', '#title' => $this->t('Advanced'), '#group' => 'additional_settings', '#description' => $this->t('The advanced settings can usually be ignored if you have no need for them.'));
        $form['advanced']['publisherID'] = array('#title' => $this->t("Insert a publisher key (optional)."), '#description' => $this->t("When you install the module, we create a random publisher key.  You can register the key with ShareThis by contacting customer support.  Otherwise, you can go to <a href='http://www.sharethis.com/account'>ShareThis</a> and create an account.<br />Your official publisher key can be found under 'My Account'.<br />It allows you to get detailed analytics about sharing done on your site."), '#type' => 'textfield', '#default_value' => $publisher);
        $form['advanced']['late_load'] = array('#title' => $this->t('Late Load'), '#description' => $this->t("You can change the order in which ShareThis widget loads on the user's browser. By default the ShareThis widget loader loads as soon as the browser encounters the JavaScript tag; typically in the tag of your page. ShareThis assets are generally loaded from a CDN closest to the user. However, if you wish to change the default setting so that the widget loads after your web-page has completed loading then you simply tick this option."), '#type' => 'checkbox', '#default_value' => $config->get('late_load'));
        $form['advanced']['twitter_suffix'] = array('#title' => $this->t("Twitter Suffix"), '#description' => $this->t("Optionally append a Twitter handle, or text, so that you get pinged when someone shares an article. Example: <em>via @YourNameHere</em>"), '#type' => 'textfield', '#default_value' => $config->get('twitter_suffix'));
        $form['advanced']['twitter_handle'] = array('#title' => $this->t('Twitter Handle'), '#description' => $this->t('Twitter handle to use when sharing.'), '#type' => 'textfield', '#default_value' => $config->get('twitter_handle'));
        $form['advanced']['twitter_recommends'] = array('#title' => $this->t('Twitter recommends'), '#description' => $this->t('Specify a twitter handle to be recommended to the user.'), '#type' => 'textfield', '#default_value' => $config->get('twitter_recommends'));
        $form['advanced']['option_onhover'] = array('#type' => 'checkbox', '#title' => $this->t('Display ShareThis widget on hover'), '#description' => $this->t('If disabled, the ShareThis widget will be displayed on click instead of hover.'), '#default_value' => $config->get('option_onhover'));
        $form['advanced']['option_neworzero'] = array('#type' => 'checkbox', '#title' => $this->t('Display count "0" instead of "New"'), '#description' => $this->t('Display a zero (0) instead of "New" in the count for content not yet shared.'), '#default_value' => $config->get('option_neworzero'));
        $form['advanced']['option_shorten'] = array('#type' => 'checkbox', '#title' => $this->t('Display short URL'), '#description' => $this->t('Display either the full or the shortened URL.'), '#default_value' => $config->get('option_shorten'));
        $form['advanced']['cns'] = array('#title' => $this->t('<b>CopyNShare </b><sup>(<a href="http://support.sharethis.com/customer/portal/articles/517332-share-widget-faqs#copynshare" target="_blank">?</a>)</sup>'), '#type' => 'checkboxes', '#prefix' => '<div id="st_cns_settings">', '#suffix' => '</div><div class="st_cns_container">
				<p>CopyNShare is the new ShareThis widget feature that enables you to track the shares that occur when a user copies and pastes your website\'s <u>URL</u> or <u>Content</u>. <br/>
				<u>Site URL</u> - ShareThis adds a special #hashtag at the end of your address bar URL to keep track of where your content is being shared on the web.<br/>
				<u>Site Content</u> - It enables the pasting of "See more: YourURL#SThashtag" after user copies-and-pastes text. When a user copies text within your site, a "See more: yourURL.com#SThashtag" will appear after the pasted text. <br/>
				Please refer the <a href="http://support.sharethis.com/customer/portal/articles/517332-share-widget-faqs#copynshare" target="_blank">CopyNShare FAQ</a> for more details.</p>
			</div>', '#options' => array('donotcopy' => $this->t("Measure copy & shares of your site's Content"), 'hashaddress' => $this->t("Measure copy & shares of your site's URLs")), '#default_value' => $config->get('cns'));
        $form['#attached']['drupalSettings']['sharethis']['service_string_markup'] = $service_string_markup;
        $form['#attached']['library'][] = 'sharethis/drupal.sharethisform';
        $form['#attached']['library'][] = 'sharethis/drupal.sharethispicker';
        $form['#attached']['library'][] = 'sharethis/drupal.sharethispickerexternal';
        return parent::buildForm($form, $form_state);
    }