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


PHP EntityTypeManagerInterface::getDefinitions方法代码示例

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


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

示例1: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection) {
   foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
     if ($route = $this->getEntityCloneRoute($entity_type)) {
       $collection->add("entity.$entity_type_id.clone_form", $route);
     }
   }
 }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:10,代码来源:RouteSubscriber.php

示例2: setUpEntityTypeDefinitions

 /**
  * Sets up the entity type manager to be tested.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface[]|\Prophecy\Prophecy\ProphecyInterface[] $definitions
  *   (optional) An array of entity type definitions.
  */
 protected function setUpEntityTypeDefinitions($definitions = [])
 {
     $class = $this->getMockClass(EntityInterface::class);
     foreach ($definitions as $key => $entity_type) {
         // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
         // by \Drupal\Core\Entity\EntityManager::processDefinition() so it must
         // always be mocked.
         $entity_type->getLinkTemplates()->willReturn([]);
         // Give the entity type a legitimate class to return.
         $entity_type->getClass()->willReturn($class);
         $definitions[$key] = $entity_type->reveal();
     }
     $this->entityTypeManager->getDefinition(Argument::cetera())->will(function ($args) use($definitions) {
         $entity_type_id = $args[0];
         $exception_on_invalid = $args[1];
         if (isset($definitions[$entity_type_id])) {
             return $definitions[$entity_type_id];
         } elseif (!$exception_on_invalid) {
             return NULL;
         } else {
             throw new PluginNotFoundException($entity_type_id);
         }
     });
     $this->entityTypeManager->getDefinitions()->willReturn($definitions);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:EntityTypeRepositoryTest.php

示例3: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($route = $this->getRdfExportRoute($entity_type)) {
             $collection->add("entity.{$entity_type_id}.rdf_export", $route);
             $collection->add("entity.{$entity_type_id}.rdf_export_download", $this->getDownloadRoute($entity_type));
         }
     }
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:12,代码来源:RouteSubscriber.php

示例4: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityTypeManager->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->entityTypeManager->hasHandler($entity_type_id, 'view_builder')) {
             $this->derivatives[$entity_type_id] = array('id' => 'ds_entity:' . $entity_type_id, 'provider' => 'ds', 'title' => 'Display Suite: ' . $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:neeravbm,项目名称:unify-d8,代码行数:13,代码来源:DsEntityRow.php

示例5: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($devel_render = $entity_type->getLinkTemplate('token-devel')) {
             $options = ['_admin_route' => TRUE, '_token_entity_type_id' => $entity_type_id, 'parameters' => [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]];
             $route = new Route($devel_render, ['_controller' => '\\Drupal\\token\\Controller\\TokenDevelController::entityTokens', '_title' => 'Devel Tokens'], ['_permission' => 'access devel information', '_module_dependencies' => 'devel'], $options);
             $collection->add("entity.{$entity_type_id}.token_devel", $route);
         }
     }
 }
开发者ID:Wylbur,项目名称:gj,代码行数:13,代码来源:RouteSubscriber.php

示例6: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Only allow content entities and ignore configuration entities.
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         $this->derivatives["entity:{$entity_type_id}"] = ['label' => $this->t('Create @entity_type path alias', ['@entity_type' => $entity_type->getLowercaseLabel()]), 'category' => $this->t('Path'), 'entity_type_id' => $entity_type_id, 'context' => ['entity' => ContextDefinition::create("entity:{$entity_type_id}")->setLabel($entity_type->getLabel())->setRequired(TRUE)->setDescription($this->t('The @entity_type for which to create a path alias.', ['@entity_type' => $entity_type->getLowercaseLabel()])), 'alias' => ContextDefinition::create('string')->setLabel($this->t('Path alias'))->setRequired(TRUE)->setDescription($this->t("Specify an alternative path by which the content can be accessed. For example, 'about' for an about page. Use a relative path and do not add a trailing slash."))], 'provides' => []] + $base_plugin_definition;
     }
     return $this->derivatives;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:14,代码来源:EntityPathAliasCreateDeriver.php

示例7: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($route = $this->getDevelLoadRoute($entity_type)) {
             $collection->add("entity.{$entity_type_id}.devel_load", $route);
         }
         if ($route = $this->getDevelRenderRoute($entity_type)) {
             $collection->add("entity.{$entity_type_id}.devel_render", $route);
         }
     }
 }
开发者ID:sgtsaughter,项目名称:d8portfolio,代码行数:14,代码来源:RouteSubscriber.php

示例8: permissions

  /**
   * Returns an array of entity_clone permissions.
   *
   * @return array
   *   The permission list.
   */
  public function permissions() {
    $permissions = [];

    foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
      $permissions['clone ' . $entity_type_id . ' entity'] = $this->translationManager->translate('Clone all <em>@label</em> entities', [
        '@label' => $entity_type->getLabel(),
      ]);
    }

    return $permissions;
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:17,代码来源:EntityClonePermissions.php

示例9: getEntityTypeMappings

 /**
  * {@inheritdoc}
  */
 public function getEntityTypeMappings()
 {
     if (empty($this->entityMappings)) {
         foreach ($this->entityTypeManager->getDefinitions() as $entity_type => $info) {
             $this->entityMappings[$entity_type] = $info->get('token_type') ?: $entity_type;
         }
         // Allow modules to alter the mapping array.
         $this->moduleHandler->alter('token_entity_mapping', $this->entityMappings);
     }
     return $this->entityMappings;
 }
开发者ID:Wylbur,项目名称:gj,代码行数:14,代码来源:TokenEntityMapper.php

示例10: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         // Only allow content entities and ignore configuration entities.
         if (!$entity_type instanceof ContentEntityTypeInterface) {
             continue;
         }
         $this->derivatives[$entity_type_id] = ['label' => $this->t('Before saving @entity_type', ['@entity_type' => $entity_type->getLowercaseLabel()]), 'category' => $entity_type->getLabel(), 'entity_type_id' => $entity_type_id, 'context' => [$entity_type_id => ['type' => "entity:{$entity_type_id}", 'label' => $entity_type->getLabel()]]] + $base_plugin_definition;
     }
     return $this->derivatives;
 }
开发者ID:Progressable,项目名称:openway8,代码行数:14,代码来源:EntityPresaveDeriver.php

示例11: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         $base_table = $entity_type->getBaseTable();
         if ($entity_type->get('field_ui_base_route') && !empty($base_table)) {
             if ($display = $entity_type->getLinkTemplate('display')) {
                 $route = new Route($display, array('_controller' => '\\Drupal\\ds\\Controller\\DsController::contextualTab', '_title' => 'Manage display', 'entity_type_id' => $entity_type_id), array('_field_ui_view_mode_access' => 'administer ' . $entity_type_id . ' display'), array('_admin_route' => TRUE, '_ds_entity_type_id' => $entity_type_id, 'parameters' => array($entity_type_id => array('type' => 'entity:' . $entity_type_id))));
                 $collection->add("entity.{$entity_type_id}.display", $route);
             }
         }
     }
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:15,代码来源:RouteSubscriber.php

示例12: form

  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);
    $lineItemType = $this->entity;
    // Prepare the list of purchasable entity types.
    $entityTypes = $this->entityTypeManager->getDefinitions();
    $purchasableEntityTypes = array_filter($entityTypes, function ($entityType) {
      return $entityType->isSubclassOf('\Drupal\commerce\PurchasableEntityInterface');
    });
    $purchasableEntityTypes = array_map(function ($entityType) {
      return $entityType->getLabel();
    }, $purchasableEntityTypes);
    // Prepare the list of order types.
    $orderTypes = $this->entityTypeManager->getStorage('commerce_order_type')
      ->loadMultiple();
    $orderTypes = array_map(function ($orderType) {
      return $orderType->label();
    }, $orderTypes);

    $form['label'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Label'),
      '#maxlength' => 255,
      '#default_value' => $lineItemType->label(),
      '#description' => $this->t('Label for the line item type.'),
      '#required' => TRUE,
    ];
    $form['id'] = [
      '#type' => 'machine_name',
      '#default_value' => $lineItemType->id(),
      '#machine_name' => [
        'exists' => '\Drupal\commerce_order\Entity\LineItemType::load',
        'source' => ['label'],
      ],
      '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH,
    ];
    $form['purchasableEntityType'] = [
      '#type' => 'select',
      '#title' => $this->t('Purchasable entity type'),
      '#default_value' => $lineItemType->getPurchasableEntityType(),
      '#options' => $purchasableEntityTypes,
      '#empty_value' => '',
      '#disabled' => !$lineItemType->isNew(),
    ];
    $form['orderType'] = [
      '#type' => 'select',
      '#title' => $this->t('Order type'),
      '#default_value' => $lineItemType->getOrderType(),
      '#options' => $orderTypes,
      '#required' => TRUE,
    ];

    return $this->protectBundleIdElement($form);
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:56,代码来源:LineItemTypeForm.php

示例13: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->hasLinkTemplate('devel-markup')) {
             $options = array('_admin_route' => TRUE, '_devel_entity_type_id' => $entity_type_id, 'parameters' => array($entity_type_id => array('type' => 'entity:' . $entity_type_id)));
             if ($devel_render = $entity_type->getLinkTemplate('devel-markup')) {
                 $route = new Route($devel_render, array('_controller' => '\\Drupal\\ds_devel\\Controller\\DsDevelController::entityMarkup', '_title' => 'Devel Render'), array('_permission' => 'access devel information'), $options);
                 $collection->add("entity.{$entity_type_id}.devel_markup", $route);
             }
         }
     }
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:15,代码来源:RouteSubscriber.php

示例14: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = array();
     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
         if ($entity_type->hasLinkTemplate('display')) {
             $this->derivatives["{$entity_type_id}.display_tab"] = array('route_name' => "entity.{$entity_type_id}.display", 'weight' => 10, 'title' => $this->t('Manage display'), 'base_route' => "entity.{$entity_type_id}.canonical");
         }
     }
     foreach ($this->derivatives as &$entry) {
         $entry += $base_plugin_definition;
     }
     return $this->derivatives;
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:16,代码来源:DsLocalTask.php

示例15: getSupportedEntityTypesList

 /**
  * Get a list of supported entity types suitable for a select list.
  *
  * @return array
  */
 public function getSupportedEntityTypesList()
 {
     $definitions = $this->entityTypeManager->getDefinitions();
     $supported = [];
     foreach ($definitions as $definition) {
         // Only support fieldable entity types.
         if (!$definition->get('field_ui_base_route')) {
             continue;
         }
         $supported[$definition->id()] = $definition->getLabel();
     }
     return $supported;
 }
开发者ID:oddhill,项目名称:entity_layout,代码行数:18,代码来源:EntityLayoutService.php


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