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


PHP EntityManagerInterface::getDefinitions方法代码示例

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


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

示例1: getDerivativeDefinitions

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    $this->derivatives = array();

    foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
      if ($entity_type_id == 'scheduled_update') {
        continue;
      }
      if ($entity_type->get('field_ui_base_route')) {
        $this->derivatives["scheduled_update_field_add_$entity_type_id"] = array(
          'route_name' => "entity.scheduled_update_type.add_form.field.$entity_type_id",
          'title' => $this->t('Add Update field'),
          'appears_on' => array("entity.$entity_type_id.field_ui_fields"),
          'query' => ['entity_type_id' => $entity_type_id],
          'route_parameters' => ['entity_type_id' => $entity_type_id],
          'defaults' => ['mode' => 'embedded'],
        );
      }
    }

    foreach ($this->derivatives as &$entry) {
      $entry += $base_plugin_definition;
    }

    return $this->derivatives;
  }
开发者ID:joebachana,项目名称:usatne,代码行数:28,代码来源:AddUpdateFieldLocalAction.php

示例2: setContentTypeSelect

 /**
  * Adds content entity types checkboxes.
  */
 protected function setContentTypeSelect(&$form, $defaults, $type, $exclude_has_config_bundles = TRUE)
 {
     $entity_types = $this->entityManager->getDefinitions();
     $has_config_bundle = array();
     foreach ($entity_types as $definition) {
         if ($entity_type_id = $definition->getBundleOf()) {
             $has_config_bundle[] = $entity_type_id;
         }
     }
     $options = array();
     foreach ($entity_types as $entity_type_id => $entity_type) {
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         if ($exclude_has_config_bundles && in_array($entity_type_id, $has_config_bundle)) {
             continue;
         }
         $options[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
     }
     // Sort the entity types by label.
     uasort($options, 'strnatcasecmp');
     if (!isset($form['types'])) {
         $form['types'] = array('#type' => 'container', '#tree' => TRUE);
     }
     $form['types']['content'] = array('#type' => 'checkboxes', '#title' => $this->t('Content entity types'), '#description' => $this->t('Select content entity types that should be considered @type types.', array('@type' => $type)), '#options' => $options, '#default_value' => $defaults);
 }
开发者ID:selwynpolit,项目名称:d8_test2,代码行数:29,代码来源:AssignmentFormBase.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: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $comment_type = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $comment_type->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $comment_type->id(), '#machine_name' => array('exists' => '\\Drupal\\comment\\Entity\\CommentType::load'), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#disabled' => !$comment_type->isNew());
     $form['description'] = array('#type' => 'textarea', '#default_value' => $comment_type->getDescription(), '#description' => t('Describe this comment type. The text will be displayed on the <em>Comment types</em> administration overview page.'), '#title' => t('Description'));
     if ($comment_type->isNew()) {
         $options = array();
         foreach ($this->entityManager->getDefinitions() as $entity_type) {
             // Only expose entities that have field UI enabled, only those can
             // get comment fields added in the UI.
             if ($entity_type->get('field_ui_base_route')) {
                 $options[$entity_type->id()] = $entity_type->getLabel();
             }
         }
         $form['target_entity_type_id'] = array('#type' => 'select', '#default_value' => $comment_type->getTargetEntityTypeId(), '#title' => t('Target entity type'), '#options' => $options, '#description' => t('The target entity type can not be changed after the comment type has been created.'));
     } else {
         $form['target_entity_type_id_display'] = array('#type' => 'item', '#markup' => $this->entityManager->getDefinition($comment_type->getTargetEntityTypeId())->getLabel(), '#title' => t('Target entity type'));
     }
     if ($this->moduleHandler->moduleExists('content_translation')) {
         $form['language'] = array('#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings');
         $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('comment', $comment_type->id());
         $form['language']['language_configuration'] = array('#type' => 'language_configuration', '#entity_information' => array('entity_type' => 'comment', 'bundle' => $comment_type->id()), '#default_value' => $language_configuration);
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'));
     return $form;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:33,代码来源:CommentTypeForm.php

示例5: 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

示例6: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('xmlsitemap.settings');
     $entity_types = $this->entityManager->getDefinitions();
     $labels = array();
     $default = array();
     $anonymous_user = new AnonymousUserSession();
     $bundles = $this->entityManager->getAllBundleInfo();
     foreach ($entity_types as $entity_type_id => $entity_type) {
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         $labels[$entity_type_id] = $entity_type->getLabel() ?: $entity_type_id;
     }
     asort($labels);
     $form = array('#labels' => $labels);
     $form['entity_types'] = array('#title' => $this->t('Custom sitemap entities settings'), '#type' => 'checkboxes', '#options' => $labels, '#default_value' => $default);
     $form['settings'] = array('#tree' => TRUE);
     foreach ($labels as $entity_type_id => $label) {
         $entity_type = $entity_types[$entity_type_id];
         $form['settings'][$entity_type_id] = array('#type' => 'container', '#entity_type' => $entity_type_id, '#bundle_label' => $entity_type->getBundleLabel() ? $entity_type->getBundleLabel() : $label, '#title' => $entity_type->getBundleLabel() ? $entity_type->getBundleLabel() : $label, '#states' => array('visible' => array(':input[name="entity_types[' . $entity_type_id . ']"]' => array('checked' => TRUE))), 'types' => array('#type' => 'table', '#tableselect' => TRUE, '#default_value' => array(), '#header' => array(array('data' => $entity_type->getBundleLabel() ? $entity_type->getBundleLabel() : $label, 'class' => array('bundle')), array('data' => $this->t('Sitemap settings'), 'class' => array('operations'))), '#empty' => $this->t('No content available.')));
         foreach ($bundles[$entity_type_id] as $bundle => $bundle_info) {
             $form['settings'][$entity_type_id][$bundle]['settings'] = array('#type' => 'item', '#label' => $bundle_info['label']);
             $form['settings'][$entity_type_id]['types'][$bundle] = array('bundle' => array('#markup' => SafeMarkup::checkPlain($bundle_info['label'])), 'operations' => ['#type' => 'operations', '#links' => ['configure' => ['title' => $this->t('Configure'), 'url' => Url::fromRoute('xmlsitemap.admin_settings_bundle', array('entity' => $entity_type_id, 'bundle' => $bundle, 'query' => drupal_get_destination()))]]]);
             $form['settings'][$entity_type_id]['types']['#default_value'][$bundle] = xmlsitemap_link_bundle_check_enabled($entity_type_id, $bundle);
             if (xmlsitemap_link_bundle_check_enabled($entity_type_id, $bundle)) {
                 $default[$entity_type_id] = $entity_type_id;
             }
         }
     }
     $form['entity_types']['#default_value'] = $default;
     $form = parent::buildForm($form, $form_state);
     $form['actions']['submit']['#value'] = $this->t('Save');
     return $form;
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:38,代码来源:XmlSitemapEntitiesSettingsForm.php

示例7: onConfigImporterImport

 /**
  * Listener for the ConfigImporter import event.
  */
 public function onConfigImporterImport()
 {
     $entity_types = array_filter($this->entityManager->getDefinitions(), function (EntityTypeInterface $entity_type) {
         return $entity_type->isTranslatable();
     });
     $this->updateDefinitions($entity_types);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:ContentTranslationUpdatesManager.php

示例8: getParticipatingEntityTypes

 /**
  * Gets a list of participating entity types.
  *
  * The list consists of all content entity types with a delete-multiple-form
  * link template.
  *
  * @return \Drupal\Core\Entity\EntityTypeInterface[]
  *   The participating entity types, keyed by entity type id.
  */
 protected function getParticipatingEntityTypes()
 {
     $entity_types = $this->entityTypeManager->getDefinitions();
     $entity_types = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
         return $entity_type->isSubclassOf(ContentEntityInterface::class) && $entity_type->hasLinkTemplate('delete-multiple-form');
     });
     return $entity_types;
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:17,代码来源:DeleteActionDeriver.php

示例9: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $entity_types = $this->entityManager->getDefinitions();
     $this->derivatives = array();
     foreach ($entity_types as $entity_type_id => $entity_type) {
         $this->derivatives[$entity_type_id] = array('id' => 'entity:' . $entity_type_id, 'provider' => 'views', 'title' => $entity_type->getLabel(), 'help' => $this->t('Validate @label', array('@label' => $entity_type->getLabel())), 'entity_type' => $entity_type_id, 'class' => $base_plugin_definition['class']);
     }
     return $this->derivatives;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:12,代码来源:ViewsEntityArgumentValidator.php

示例10: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         $this->derivatives[$entity_type_id] = $base_plugin_definition;
         $this->derivatives[$entity_type_id]['entity_types'] = array($entity_type_id);
         $this->derivatives[$entity_type_id]['label'] = t('@entity_type selection', array('@entity_type' => $entity_type->getLabel()));
         $this->derivatives[$entity_type_id]['base_plugin_label'] = (string) $base_plugin_definition['label'];
     }
     return parent::getDerivativeDefinitions($base_plugin_definition);
 }
开发者ID:dev981,项目名称:gaptest,代码行数:13,代码来源:SelectionBase.php

示例11: onMigrateImport

 /**
  * Listener for migration imports.
  */
 public function onMigrateImport(MigrateImportEvent $event)
 {
     $migration = $event->getMigration();
     $configuration = $migration->getDestinationConfiguration();
     $entity_types = NestedArray::getValue($configuration, ['content_translation_update_definitions']);
     if ($entity_types) {
         $entity_types = array_intersect_key($this->entityManager->getDefinitions(), array_flip($entity_types));
         $this->updateDefinitions($entity_types);
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:ContentTranslationUpdatesManager.php

示例12: autoEntityLabelPermissions

 /**
  * Returns an array of auto_entitylabel permissions
  *
  * @return array
  */
 public function autoEntityLabelPermissions()
 {
     $permissions = [];
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Create a permission for each fieldable entity to manage
         // the entity labels.
         $permissions['administer ' . $entity_type_id . ' labels'] = ['title' => $this->t('%entity_label: Administer Entity Labels', ['%entity_label' => $entity_type->getLabel()]), 'restrict access' => TRUE];
     }
     return $permissions;
 }
开发者ID:itspkrai,项目名称:auto_entitylabel,代码行数:15,代码来源:AutoEntityLabelPermisssionController.php

示例13: getSupportedEntityTypes

 /**
  * {@inheritdoc}
  */
 public function getSupportedEntityTypes()
 {
     $supported_types = array();
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($this->isSupported($entity_type_id)) {
             $supported_types[$entity_type_id] = $entity_type;
         }
     }
     return $supported_types;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:13,代码来源:ContentTranslationManager.php

示例14: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Just add support for entity types which have a views integration.
         if (($base_table = $entity_type->getBaseTable()) && $this->viewsData->get($base_table) && $this->entityManager->hasHandler($entity_type_id, 'view_builder')) {
             $this->derivatives[$entity_type_id] = array('id' => 'entity:' . $entity_type_id, 'provider' => 'views', 'title' => $entity_type->getLabel(), 'help' => t('Display the @label', array('@label' => $entity_type->getLabel())), 'base' => array($entity_type->getDataTable() ?: $entity_type->getBaseTable()), 'entity_type' => $entity_type_id, 'display_types' => array('normal'), 'class' => $base_plugin_definition['class']);
         }
     }
     return $this->derivatives;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:13,代码来源:ViewsEntityRow.php

示例15: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->hasViewBuilderClass()) {
             $this->derivatives[$entity_type_id] = $base_plugin_definition;
             $this->derivatives[$entity_type_id]['admin_label'] = $this->t('Entity view (@label)', ['@label' => $entity_type->getLabel()]);
             $this->derivatives[$entity_type_id]['context'] = ['entity' => new ContextDefinition('entity:' . $entity_type_id)];
         }
     }
     return $this->derivatives;
 }
开发者ID:pulibrary,项目名称:recap,代码行数:14,代码来源:EntityViewDeriver.php


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