• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Entity\EntityStorageInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: loadMultiple

 /**
  * {@inheritdoc}
  */
 public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL)
 {
     /** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
     $bundle_migration = $storage->load('d6_taxonomy_vocabulary');
     $migrate_executable = new MigrateExecutable($bundle_migration, new MigrateMessage());
     $process = array_intersect_key($bundle_migration->get('process'), $bundle_migration->getDestinationPlugin()->getIds());
     $migrations = array();
     $vid_map = array();
     foreach ($bundle_migration->getIdMap() as $key => $value) {
         $old_vid = unserialize($key)['sourceid1'];
         $new_vid = $value['destid1'];
         $vid_map[$old_vid] = $new_vid;
     }
     foreach ($bundle_migration->getSourcePlugin()->getIterator() as $source_row) {
         $row = new Row($source_row, $source_row);
         $migrate_executable->processRow($row, $process);
         $old_vid = $source_row['vid'];
         $new_vid = $row->getDestinationProperty('vid');
         $vid_map[$old_vid] = $new_vid;
     }
     foreach ($vid_map as $old_vid => $new_vid) {
         $values = $this->migration->toArray();
         $migration_id = $this->migration->id() . ':' . $old_vid;
         $values['id'] = $migration_id;
         $values['source']['vid'] = $old_vid;
         $values['process'][$new_vid] = 'tid';
         $migrations[$migration_id] = $storage->create($values);
     }
     return $migrations;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:33,代码来源:LoadTermNode.php


示例2: loadMultiple

 /**
  * {@inheritdoc}
  */
 public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = NULL)
 {
     if (isset($this->configuration['bundle_migration'])) {
         /** @var \Drupal\migrate\Entity\MigrationInterface $bundle_migration */
         $bundle_migration = $storage->load($this->configuration['bundle_migration']);
         $source_id = array_keys($bundle_migration->getSourcePlugin()->getIds())[0];
         $this->bundles = array();
         foreach ($bundle_migration->getSourcePlugin()->getIterator() as $row) {
             $this->bundles[] = $row[$source_id];
         }
     } else {
         // This entity type has no bundles ('user', 'feed', etc).
         $this->bundles = array($this->migration->getSourcePlugin()->entityTypeId());
     }
     $sub_ids_to_load = isset($sub_ids) ? array_intersect($this->bundles, $sub_ids) : $this->bundles;
     $migrations = array();
     foreach ($sub_ids_to_load as $id) {
         $values = $this->migration->toArray();
         $values['id'] = $this->migration->id() . ':' . $id;
         $values['source']['bundle'] = $id;
         /** @var \Drupal\migrate_drupal\Entity\MigrationInterface $migration */
         $migration = $storage->create($values);
         if ($migration->getSourcePlugin()->checkRequirements()) {
             $fields = array_keys($migration->getSourcePlugin()->fields());
             $migration->process += array_combine($fields, $fields);
             $migrations[$migration->id()] = $migration;
         }
     }
     return $migrations;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:33,代码来源:LoadEntity.php


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


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


示例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'];
                 $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


示例7: testImportEntityLoadFailure

 /**
  * Test row skipping when we can't get an entity to save.
  *
  * @covers ::import
  * @expectedException \Drupal\migrate\MigrateException
  * @expectedExceptionMessage Unable to get entity
  */
 public function testImportEntityLoadFailure()
 {
     $bundles = [];
     $destination = new EntityTestDestination([], '', [], $this->migration->reveal(), $this->storage->reveal(), $bundles, $this->entityManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal());
     $destination->setEntity(FALSE);
     $destination->import(new Row([], []));
 }
开发者ID:318io,项目名称:318-io,代码行数:14,代码来源:EntityContentBaseTest.php


示例8: transform

 /**
  * {@inheritdoc}
  *
  * Find the parent link GUID.
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     $parent_id = array_shift($value);
     if (!$parent_id) {
         // Top level item.
         return '';
     }
     try {
         $already_migrated_id = $this->migrationPlugin->transform($parent_id, $migrate_executable, $row, $destination_property);
         if ($already_migrated_id && ($link = $this->menuLinkStorage->load($already_migrated_id))) {
             return $link->getPluginId();
         }
     } catch (MigrateSkipRowException $e) {
     }
     if (isset($value[1])) {
         list($menu_name, $parent_link_path) = $value;
         $url = Url::fromUserInput("/{$parent_link_path}");
         if ($url->isRouted()) {
             $links = $this->menuLinkManager->loadLinksByRoute($url->getRouteName(), $url->getRouteParameters(), $menu_name);
             if (count($links) == 1) {
                 /** @var \Drupal\Core\Menu\MenuLinkInterface $link */
                 $link = reset($links);
                 return $link->getPluginId();
             }
         }
     }
     throw new MigrateSkipRowException();
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:33,代码来源:MenuLinkParent.php


示例9: resolveCurrencyLocale

 /**
  * {@inheritdoc}
  */
 public function resolveCurrencyLocale($language_type = LanguageInterface::TYPE_CONTENT)
 {
     if (empty($this->currencyLocales[$language_type])) {
         $currency_locale = NULL;
         $language_code = $this->languageManager->getCurrentLanguage($language_type)->getId();
         // Try this request's country code.
         $country_code = $this->eventDispatcher->resolveCountryCode();
         if ($country_code) {
             $currency_locale = $this->currencyLocaleStorage->load($language_code . '_' . $country_code);
         }
         // Try the site's default country code.
         if (!$currency_locale) {
             $country_code = $this->configFactory->get('system.data')->get('country.default');
             if ($country_code) {
                 $currency_locale = $this->currencyLocaleStorage->load($language_code . '_' . $country_code);
             }
         }
         // Try the Currency default.
         if (!$currency_locale) {
             $currency_locale = $this->currencyLocaleStorage->load($this::DEFAULT_LOCALE);
         }
         if ($currency_locale) {
             $this->currencyLocales[$language_type] = $currency_locale;
         } else {
             throw new \RuntimeException(sprintf('The currency locale for %s could not be loaded.', $this::DEFAULT_LOCALE));
         }
     }
     return $this->currencyLocales[$language_type];
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:32,代码来源:LocaleResolver.php


示例10: testGetUniqueMachineName

 /**
  * Tests the unique machine name generator.
  *
  * @see \Drupal\block\BlockForm::getUniqueMachineName()
  */
 public function testGetUniqueMachineName()
 {
     $blocks = array();
     $blocks['test'] = $this->getBlockMockWithMachineName('test');
     $blocks['other_test'] = $this->getBlockMockWithMachineName('other_test');
     $blocks['other_test_1'] = $this->getBlockMockWithMachineName('other_test');
     $blocks['other_test_2'] = $this->getBlockMockWithMachineName('other_test');
     $query = $this->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
     $query->expects($this->exactly(5))->method('condition')->will($this->returnValue($query));
     $query->expects($this->exactly(5))->method('execute')->will($this->returnValue(array('test', 'other_test', 'other_test_1', 'other_test_2')));
     $this->storage->expects($this->exactly(5))->method('getQuery')->will($this->returnValue($query));
     $block_form_controller = new BlockForm($this->entityManager, $this->conditionManager, $this->contextRepository, $this->language, $this->themeHandler);
     // Ensure that the block with just one other instance gets the next available
     // name suggestion.
     $this->assertEquals('test_2', $block_form_controller->getUniqueMachineName($blocks['test']));
     // Ensure that the block with already three instances (_0, _1, _2) gets the
     // 4th available name.
     $this->assertEquals('other_test_3', $block_form_controller->getUniqueMachineName($blocks['other_test']));
     $this->assertEquals('other_test_3', $block_form_controller->getUniqueMachineName($blocks['other_test_1']));
     $this->assertEquals('other_test_3', $block_form_controller->getUniqueMachineName($blocks['other_test_2']));
     // Ensure that a block without an instance yet gets the suggestion as
     // unique machine name.
     $last_block = $this->getBlockMockWithMachineName('last_test');
     $this->assertEquals('last_test', $block_form_controller->getUniqueMachineName($last_block));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:30,代码来源:BlockFormTest.php


示例11: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // TODO: Change the autogenerated stub
     $condition_plugin_manager = $this->getMock('Drupal\\Core\\Executable\\ExecutableManagerInterface');
     $condition_plugin_manager->expects($this->any())->method('getDefinitions')->will($this->returnValue(array()));
     $container = new ContainerBuilder();
     $container->set('plugin.manager.condition', $condition_plugin_manager);
     \Drupal::setContainer($container);
     $this->executable = $this->getMockBuilder('Drupal\\views\\ViewExecutable')->disableOriginalConstructor()->setMethods(['buildRenderable', 'setDisplay', 'setItemsPerPage'])->getMock();
     $this->executable->expects($this->any())->method('setDisplay')->with('block_1')->will($this->returnValue(TRUE));
     $this->executable->expects($this->any())->method('getShowAdminLinks')->willReturn(FALSE);
     $this->executable->display_handler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')->disableOriginalConstructor()->setMethods(NULL)->getMock();
     $this->view = $this->getMockBuilder('Drupal\\views\\Entity\\View')->disableOriginalConstructor()->getMock();
     $this->view->expects($this->any())->method('id')->willReturn('test_view');
     $this->executable->storage = $this->view;
     $this->executableFactory = $this->getMockBuilder('Drupal\\views\\ViewExecutableFactory')->disableOriginalConstructor()->getMock();
     $this->executableFactory->expects($this->any())->method('get')->with($this->view)->will($this->returnValue($this->executable));
     $this->displayHandler = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\Block')->disableOriginalConstructor()->getMock();
     $this->displayHandler->expects($this->any())->method('blockSettings')->willReturn([]);
     $this->displayHandler->expects($this->any())->method('getPluginId')->willReturn('block');
     $this->executable->display_handler = $this->displayHandler;
     $this->storage = $this->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')->disableOriginalConstructor()->getMock();
     $this->storage->expects($this->any())->method('load')->with('test_view')->will($this->returnValue($this->view));
     $this->account = $this->getMock('Drupal\\Core\\Session\\AccountInterface');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:ViewsBlockTest.php


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


示例13: transform

 /**
  * {@inheritdoc}
  *
  * Set the block plugin id.
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     if (is_array($value)) {
         list($module, $delta) = $value;
         switch ($module) {
             case 'aggregator':
                 list($type, $id) = explode('-', $delta);
                 if ($type == 'feed') {
                     return 'aggregator_feed_block';
                 }
                 break;
             case 'menu':
                 return "system_menu_block:{$delta}";
             case 'block':
                 if ($this->blockContentStorage) {
                     $block_id = $this->migrationPlugin->transform($delta, $migrate_executable, $row, $destination_property);
                     if ($block_id) {
                         return 'block_content:' . $this->blockContentStorage->load($block_id)->uuid();
                     }
                 }
                 break;
             default:
                 break;
         }
     } else {
         return $value;
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:33,代码来源:BlockPluginId.php


示例14: render

 /**
  * {@inheritdoc}
  */
 public function render($empty = FALSE)
 {
     if (!empty($this->options['view_to_insert'])) {
         list($view_name, $display_id) = explode(':', $this->options['view_to_insert']);
         $view = $this->viewStorage->load($view_name)->getExecutable();
         if (empty($view) || !$view->access($display_id)) {
             return array();
         }
         $view->setDisplay($display_id);
         // Avoid recursion
         $view->parent_views += $this->view->parent_views;
         $view->parent_views[] = "{$view_name}:{$display_id}";
         // Check if the view is part of the parent views of this view
         $search = "{$view_name}:{$display_id}";
         if (in_array($search, $this->view->parent_views)) {
             drupal_set_message(t("Recursion detected in view @view display @display.", array('@view' => $view_name, '@display' => $display_id)), 'error');
         } else {
             if (!empty($this->options['inherit_arguments']) && !empty($this->view->args)) {
                 $output = $view->preview($display_id, $this->view->args);
             } else {
                 $output = $view->preview($display_id);
             }
             $this->isEmpty = $view->display_handler->outputIsEmpty();
             return $output;
         }
     }
     return array();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:31,代码来源:View.php


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


示例16: match

 /**
  * {@inheritdoc}
  */
 public function match(AddressInterface $address)
 {
     $zone = $this->zoneStorage->load($this->configuration['zone']);
     if ($zone) {
         return $zone->match($address);
     }
 }
开发者ID:seongbae,项目名称:drumo-distribution,代码行数:10,代码来源:ZoneMemberZone.php


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


示例18: testConfigurableEventHandler

 /**
  * Tests ConfigurableEventHandlerEntityBundle.
  *
  * Test that rules are triggered correctly based upon the fully qualified
  * event name as well as the base event name.
  *
  * @todo Add integrity check that node.field_integer is detected by Rules.
  */
 public function testConfigurableEventHandler()
 {
     // Create rule1 with the 'rules_entity_presave:node--page' event.
     $rule1 = $this->expressionManager->createRule();
     $rule1->addAction('rules_test_log', ContextConfig::create()->map('message', 'node.field_integer.0.value'));
     $config_entity1 = $this->storage->create(['id' => 'test_rule1']);
     $config_entity1->set('events', [['event_name' => 'rules_entity_presave:node--page']]);
     $config_entity1->set('expression', $rule1->getConfiguration());
     $config_entity1->save();
     // Create rule2 with the 'rules_entity_presave:node' event.
     $rule2 = $this->expressionManager->createRule();
     $rule2->addAction('rules_test_log', ContextConfig::create()->map('message', 'node.field_integer.1.value'));
     $config_entity2 = $this->storage->create(['id' => 'test_rule2']);
     $config_entity2->set('events', [['event_name' => 'rules_entity_presave:node']]);
     $config_entity2->set('expression', $rule2->getConfiguration());
     $config_entity2->save();
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules');
     // Add node.field_integer.0.value to rules log message, read result.
     $this->node->field_integer->setValue(['0' => 11, '1' => 22]);
     // Trigger node save.
     $entity_type_id = $this->node->getEntityTypeId();
     $event = new EntityEvent($this->node, [$entity_type_id => $this->node]);
     $event_dispatcher = \Drupal::service('event_dispatcher');
     $event_dispatcher->dispatch("rules_entity_presave:{$entity_type_id}", $event);
     // Test that the action in the rule1 logged node value.
     $this->assertRulesLogEntryExists(11, 1);
     // Test that the action in the rule2 logged node value.
     $this->assertRulesLogEntryExists(22, 0);
 }
开发者ID:Progressable,项目名称:openway8,代码行数:38,代码来源:ConfigurableEventHandlerTest.php


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


示例20: transform

 /**
  * {@inheritdoc}
  *
  * Set the block plugin id.
  */
 public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property)
 {
     if (is_array($value)) {
         list($module, $delta) = $value;
         switch ($module) {
             case 'aggregator':
                 list($type, $id) = explode('-', $delta);
                 if ($type == 'category') {
                     // @TODO skip row.
                     // throw new MigrateSkipRowException();
                 }
                 $value = 'aggregator_feed_block';
                 break;
             case 'menu':
                 $value = "system_menu_block:{$delta}";
                 break;
             case 'block':
                 if ($this->blockContentStorage) {
                     $block_ids = $this->processPluginManager->createInstance('migration', array('migration' => 'd6_custom_block'), $this->migration)->transform($delta, $migrate_executable, $row, $destination_property);
                     $value = 'block_content:' . $this->blockContentStorage->load($block_ids[0])->uuid();
                 } else {
                     throw new MigrateSkipRowException();
                 }
                 break;
             default:
                 throw new MigrateSkipRowException();
         }
     }
     return $value;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:35,代码来源:BlockPluginId.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Entity\EntityTypeInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\EntityManagerInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap