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


PHP EntityStorageInterface::loadMultiple方法代码示例

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


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

示例1: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $book_nids = array();
     $links = array(Link::createFromRoute($this->t('Home'), '<front>'));
     $book = $route_match->getParameter('node')->book;
     $depth = 1;
     // We skip the current node.
     while (!empty($book['p' . ($depth + 1)])) {
         $book_nids[] = $book['p' . $depth];
         $depth++;
     }
     $parent_books = $this->nodeStorage->loadMultiple($book_nids);
     if (count($parent_books) > 0) {
         $depth = 1;
         while (!empty($book['p' . ($depth + 1)])) {
             if (!empty($parent_books[$book['p' . $depth]]) && ($parent_book = $parent_books[$book['p' . $depth]])) {
                 if ($parent_book->access('view', $this->account)) {
                     $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id()));
                 }
             }
             $depth++;
         }
     }
     return $links;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:28,代码来源:BookBreadcrumbBuilder.php

示例2: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->entityStorage->loadMultiple() as $entity_id => $entity) {
         /** @var $entity \Drupal\page_manager\PageInterface */
         // If the page is disabled skip making a route for it.
         if (!$entity->status() || $entity->isFallbackPage()) {
             continue;
         }
         // Prepare a route name to use if this is a custom page.
         $route_name = "page_manager.page_view_{$entity_id}";
         // Prepare the values that need to be altered for an existing page.
         $path = $entity->getPath();
         $parameters = ['page_manager_page' => ['type' => 'entity:page']];
         // Loop through all existing routes to see if this is overriding a route.
         foreach ($collection->all() as $name => $collection_route) {
             // Find all paths which match the path of the current display.
             $route_path = RouteCompiler::getPathWithoutDefaults($collection_route);
             $route_path = RouteCompiler::getPatternOutline($route_path);
             if ($path == $route_path) {
                 // Adjust the path to translate %placeholders to {slugs}.
                 $path = $collection_route->getPath();
                 // Merge in any route parameter definitions.
                 $parameters += $collection_route->getOption('parameters') ?: [];
                 // Update the route name this will be added to.
                 $route_name = $name;
                 // Remove the existing route.
                 $collection->remove($route_name);
                 break;
             }
         }
         // Construct an add a new route.
         $route = new Route($path, ['_entity_view' => 'page_manager_page', 'page_manager_page' => $entity_id, '_title' => $entity->label()], ['_entity_access' => 'page_manager_page.view'], ['parameters' => $parameters, '_admin_route' => $entity->usesAdminTheme()]);
         $collection->add($route_name, $route);
     }
 }
开发者ID:pulibrary,项目名称:recap,代码行数:38,代码来源:PageManagerRoutes.php

示例3: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     // Check all Views for block displays.
     foreach ($this->viewStorage->loadMultiple() as $view) {
         // Do not return results for disabled views.
         if (!$view->status()) {
             continue;
         }
         $executable = $view->getExecutable();
         $executable->initDisplay();
         foreach ($executable->displayHandlers as $display) {
             // Add a block plugin definition for each block display.
             if (isset($display) && !empty($display->definition['uses_hook_block'])) {
                 $delta = $view->id() . '-' . $display->display['id'];
                 $desc = $display->getOption('block_description');
                 if (empty($desc)) {
                     if ($display->display['display_title'] == $display->definition['title']) {
                         $desc = t('!view', array('!view' => $view->label()));
                     } else {
                         $desc = t('!view: !display', array('!view' => $view->label(), '!display' => $display->display['display_title']));
                     }
                 }
                 $this->derivatives[$delta] = array('category' => $display->getOption('block_category'), 'admin_label' => $desc, 'config_dependencies' => array('entity' => array($view->getConfigDependencyName())));
                 $this->derivatives[$delta] += $base_plugin_definition;
             }
         }
     }
     return $this->derivatives;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:32,代码来源:ViewsBlock.php

示例4: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     /** @var \Drupal\commerce_product\Entity\ProductTypeInterface $product_type */
     $product_type = $this->entity;
     $variation_types = $this->variationTypeStorage->loadMultiple();
     $variation_types = array_map(function ($variation_type) {
         return $variation_type->label();
     }, $variation_types);
     // Create an empty product to get the default status value.
     // @todo Clean up once https://www.drupal.org/node/2318187 is fixed.
     if ($this->operation == 'add') {
         $product = $this->entityTypeManager->getStorage('commerce_product')->create(['type' => $product_type->uuid()]);
     } else {
         $product = $this->entityTypeManager->getStorage('commerce_product')->create(['type' => $product_type->id()]);
     }
     $form['label'] = ['#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $product_type->label(), '#required' => TRUE];
     $form['id'] = ['#type' => 'machine_name', '#default_value' => $product_type->id(), '#machine_name' => ['exists' => '\\Drupal\\commerce_product\\Entity\\ProductType::load'], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH];
     $form['description'] = ['#type' => 'textfield', '#title' => $this->t('Description'), '#default_value' => $product_type->getDescription()];
     $form['variationType'] = ['#type' => 'select', '#title' => $this->t('Product variation type'), '#default_value' => $product_type->getVariationType(), '#options' => $variation_types, '#required' => TRUE];
     $form['product_status'] = ['#type' => 'checkbox', '#title' => t('Publish new products of this type by default.'), '#default_value' => $product->isPublished()];
     if ($this->moduleHandler->moduleExists('language')) {
         $form['language'] = ['#type' => 'details', '#title' => $this->t('Language settings'), '#group' => 'additional_settings'];
         $form['language']['language_configuration'] = ['#type' => 'language_configuration', '#entity_information' => ['entity_type' => 'commerce_product', 'bundle' => $product_type->id()], '#default_value' => ContentLanguageSettings::loadByEntityTypeBundle('commerce_product', $product_type->id())];
         $form['#submit'][] = 'language_configuration_element_submit';
     }
     return $this->protectBundleIdElement($form);
 }
开发者ID:marmouset,项目名称:drupal,代码行数:31,代码来源:ProductTypeForm.php

示例5: activeList

  /**
   * @param $active_group_ids
   *
   * @return array
   */
  public function activeList($active_group_ids) {
    $active_group_ids = explode(',', $active_group_ids);
    /** @var \Drupal\block_visibility_groups\Entity\BlockVisibilityGroup[] $groups */
    $groups = $this->storage->loadMultiple($active_group_ids);

    $edit_links = [];
    foreach ($groups as $group) {
      $edit_links[] = [
        '#type' => 'container',

        'edit' => [
          '#type' => 'link',
          '#title' => $group->label(),
          '#url' => $group->urlInfo('edit-form'),
          '#suffix' => ' - ',
        ],
        'manage' => [
          '#type' => 'link',
          '#title' => t('Manage Blocks'),
          '#url' => Url::fromRoute('block.admin_display_theme', [
            'theme' => \Drupal::theme()->getActiveTheme()->getName(),
          ],
            [
              'query' => ['block_visibility_group' => $group->id()],
            ]
          ),
        ],

      ];
    }
    return $edit_links;
  }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:37,代码来源:GroupLister.php

示例6: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     // Check all Views for block displays.
     foreach ($this->viewStorage->loadMultiple() as $view) {
         // Do not return results for disabled views.
         if (!$view->status()) {
             continue;
         }
         $executable = $view->getExecutable();
         $executable->initDisplay();
         foreach ($executable->displayHandlers as $display) {
             // Add a block plugin definition for each block display.
             if (isset($display) && !empty($display->definition['uses_hook_block'])) {
                 $delta = $view->id() . '-' . $display->display['id'];
                 $admin_label = $display->getOption('block_description');
                 if (empty($admin_label)) {
                     if ($display->display['display_title'] == $display->definition['title']) {
                         $admin_label = $view->label();
                     } else {
                         // Allow translators to control the punctuation. Plugin
                         // definitions get cached, so use TranslatableMarkup() instead of
                         // t() to avoid double escaping when $admin_label is rendered
                         // during requests that use the cached definition.
                         $admin_label = new TranslatableMarkup('@view: @display', ['@view' => $view->label(), '@display' => $display->display['display_title']]);
                     }
                 }
                 $this->derivatives[$delta] = array('category' => $display->getOption('block_category'), 'admin_label' => $admin_label, 'config_dependencies' => array('config' => array($view->getConfigDependencyName())));
                 $this->derivatives[$delta] += $base_plugin_definition;
             }
         }
     }
     return $this->derivatives;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:36,代码来源:ViewsBlock.php

示例7: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->entityStorage->loadMultiple() as $entity_id => $entity) {
         /** @var \Drupal\page_manager\PageInterface $entity */
         // If the page is disabled skip making a route for it.
         if (!$entity->status() || !$entity->getVariants()) {
             continue;
         }
         // Prepare the values that need to be altered for an existing page.
         $parameters = ['page_manager_page_variant' => ['type' => 'entity:page_variant'], 'page_manager_page' => ['type' => 'entity:page']];
         $requirements = [];
         if ($route_name = $this->findPageRouteName($entity, $collection)) {
             $this->cacheTagsInvalidator->invalidateTags(["page_manager_route_name:{$route_name}"]);
             $collection_route = $collection->get($route_name);
             $path = $collection_route->getPath();
             $parameters += $collection_route->getOption('parameters') ?: [];
             $requirements += $collection_route->getRequirements();
             $collection->remove($route_name);
         } else {
             $route_name = "page_manager.page_view_{$entity_id}";
             $path = $entity->getPath();
             $requirements['_entity_access'] = 'page_manager_page.view';
         }
         $page_id = $entity->id();
         $first = TRUE;
         foreach ($entity->getVariants() as $variant_id => $variant) {
             // Construct and add a new route.
             $route = new Route($path, ['_entity_view' => 'page_manager_page_variant', '_title' => $entity->label(), 'page_manager_page_variant' => $variant_id, 'page_manager_page' => $page_id, 'base_route_name' => $route_name], $requirements, ['parameters' => $parameters, '_admin_route' => $entity->usesAdminTheme()]);
             $collection->add($first ? $route_name : $route_name . '_' . $variant_id, $route);
             $first = FALSE;
         }
     }
 }
开发者ID:AllieRays,项目名称:debugging-drupal-8,代码行数:36,代码来源:PageManagerRoutes.php

示例8: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $book_nids = array();
     $breadcrumb = new Breadcrumb();
     $links = array(Link::createFromRoute($this->t('Home'), '<front>'));
     $book = $route_match->getParameter('node')->book;
     $depth = 1;
     // We skip the current node.
     while (!empty($book['p' . ($depth + 1)])) {
         $book_nids[] = $book['p' . $depth];
         $depth++;
     }
     $parent_books = $this->nodeStorage->loadMultiple($book_nids);
     if (count($parent_books) > 0) {
         $depth = 1;
         while (!empty($book['p' . ($depth + 1)])) {
             if (!empty($parent_books[$book['p' . $depth]]) && ($parent_book = $parent_books[$book['p' . $depth]])) {
                 $access = $parent_book->access('view', $this->account, TRUE);
                 $breadcrumb->addCacheableDependency($access);
                 if ($access->isAllowed()) {
                     $breadcrumb->addCacheableDependency($parent_book);
                     $links[] = Link::createFromRoute($parent_book->label(), 'entity.node.canonical', array('node' => $parent_book->id()));
                 }
             }
             $depth++;
         }
     }
     $breadcrumb->setLinks($links);
     $breadcrumb->addCacheContexts(['route.book_navigation']);
     return $breadcrumb;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:34,代码来源:BookBreadcrumbBuilder.php

示例9: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $derivatives = [];
     foreach ($this->storage->loadMultiple() as $feed_type) {
         $derivatives[$feed_type->id()] = $base_plugin_definition;
     }
     return $derivatives;
 }
开发者ID:Tawreh,项目名称:mtg,代码行数:11,代码来源:FeedQueueWorker.php

示例10: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     foreach ($this->menuStorage->loadMultiple() as $menu => $entity) {
         $this->derivatives[$menu] = $base_plugin_definition;
         $this->derivatives[$menu]['admin_label'] = $entity->label();
         $this->derivatives[$menu]['config_dependencies']['config'] = array($entity->getConfigDependencyName());
     }
     return $this->derivatives;
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:12,代码来源:SystemMenuBlock.php

示例11: getDerivativeDefinitions

  /**
   * {@inheritdoc}
   */
  public function getDerivativeDefinitions($base_plugin_definition) {
    foreach ($this->entityStorage->loadMultiple() as $blocktabs => $entity) {
	  //drupal_set_message('123:' . $blocktabs);
      $this->derivatives[$blocktabs] = $base_plugin_definition;
      $this->derivatives[$blocktabs]['admin_label'] = 'Blocktabs:' . $entity->label();
      $this->derivatives[$blocktabs]['config_dependencies']['config'] = array($entity->getConfigDependencyName());
    }
    return $this->derivatives;
  }
开发者ID:AshishNaik021,项目名称:iimisac-d8,代码行数:12,代码来源:BlocktabsBlock.php

示例12: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     /** @var \Drupal\payment\Entity\PaymentStatusInterface[] $statuses */
     $statuses = $this->paymentStatusStorage->loadMultiple();
     foreach ($statuses as $status) {
         $this->derivatives[$status->id()] = array('description' => $status->getDescription(), 'label' => $status->label(), 'parent_id' => $status->getParentId()) + $base_plugin_definition;
     }
     return parent::getDerivativeDefinitions($base_plugin_definition);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:12,代码来源:ConfigDeriver.php

示例13: init

 /**
  * {@inheritdoc}
  */
 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL)
 {
     parent::init($view, $display, $options);
     $entity_type = $this->getEntityType();
     // Filter the actions to only include those for this entity type.
     $this->actions = array_filter($this->actionStorage->loadMultiple(), function ($action) use($entity_type) {
         return $action->getType() == $entity_type;
     });
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:12,代码来源:BulkForm.php

示例14: add

 /**
  * Displays add custom block links for available types.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request object.
  *
  * @return array
  *   A render array for a list of the custom block types that can be added or
  *   if there is only one custom block type defined for the site, the function
  *   returns the custom block add page for that custom block type.
  */
 public function add(Request $request)
 {
     $types = $this->blockContentTypeStorage->loadMultiple();
     if ($types && count($types) == 1) {
         $type = reset($types);
         return $this->addForm($type, $request);
     }
     return array('#theme' => 'block_content_add_list', '#content' => $types);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:20,代码来源:BlockContentController.php

示例15: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     // Check all menu blocks for block displays.
     foreach ($this->menuBlockStorage->loadMultiple() as $menu_block) {
         $delta = $menu_block->id();
         $this->derivatives[$delta] = array('category' => 'menu block', 'admin_label' => $menu_block->getAdminBlockTitle());
         $this->derivatives[$delta] += $base_plugin_definition;
     }
     return $this->derivatives;
 }
开发者ID:nerdstein,项目名称:menu_block,代码行数:13,代码来源:MenuBlock.php


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