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


PHP EntityManagerInterface::getBundleInfo方法代码示例

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


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

示例1: buildForm

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

示例2: setMapperDefinition

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

示例3: contentPermissions

 /**
  * 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;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:32,代码来源:ContentTranslationPermissions.php

示例4: buildConfigurationForm

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

示例5: submitForm

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

示例6: getTargetBundles

 /**
  * 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;
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:17,代码来源:InlineEntityFormBase.php

示例7: bundleOptions

 /**
  * 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;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:18,代码来源:EntityProcessorBase.php

示例8: buildGroup

  /**
   * 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;
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:22,代码来源:EntityMatcher.php

示例9: buildOptionsForm

 /**
  * {@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']);
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:27,代码来源:Entity.php

示例10: isEnabled

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

示例11: buildConfigurationForm

 /**
  * {@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;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:51,代码来源:SelectionBase.php

示例12: writeCache

 /**
  * 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'));
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:23,代码来源:RelationLinkManager.php

示例13: getFieldMap

 /**
  * 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;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:22,代码来源:MultiversionMigration.php

示例14: getBundleInfo

 /**
  * {@inheritdoc}
  */
 public function getBundleInfo($entity_type)
 {
     return $this->entityManager->getBundleInfo($entity_type);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:7,代码来源:EntityManagerWrapper.php

示例15: getBundles

 /**
  * 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()));
 }
开发者ID:AllieRays,项目名称:debugging-drupal-8,代码行数:12,代码来源:EntityAliasTypeBase.php


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