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


PHP Cache::mergeTags方法代码示例

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


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

示例1: viewMultiple

 /**
  * {@inheritdoc}
  */
 public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL)
 {
     // @todo Remove when https://www.drupal.org/node/2453059 lands.
     $default_cache_contexts = ['languages', 'theme'];
     /** @var \Drupal\block\BlockInterface[] $entities */
     $build = array();
     foreach ($entities as $entity) {
         $entity_id = $entity->id();
         $plugin = $entity->getPlugin();
         $plugin_id = $plugin->getPluginId();
         $base_id = $plugin->getBaseId();
         $derivative_id = $plugin->getDerivativeId();
         $configuration = $plugin->getConfiguration();
         // Create the render array for the block as a whole.
         // @see template_preprocess_block().
         $build[$entity_id] = array('#theme' => 'block', '#attributes' => array(), '#contextual_links' => array('block' => array('route_parameters' => array('block' => $entity->id()))), '#weight' => $entity->getWeight(), '#configuration' => $configuration, '#plugin_id' => $plugin_id, '#base_plugin_id' => $base_id, '#derivative_plugin_id' => $derivative_id, '#id' => $entity->id(), '#cache' => ['contexts' => Cache::mergeContexts($default_cache_contexts, $plugin->getCacheContexts()), 'tags' => Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags(), $plugin->getCacheTags()), 'max-age' => $plugin->getCacheMaxAge()], '#block' => $entity);
         $build[$entity_id]['#configuration']['label'] = String::checkPlain($configuration['label']);
         if ($plugin->isCacheable()) {
             $build[$entity_id]['#pre_render'][] = array($this, 'buildBlock');
             // Generic cache keys, with the block plugin's custom keys appended.
             $default_cache_keys = array('entity_view', 'block', $entity->id());
             $build[$entity_id]['#cache']['keys'] = array_merge($default_cache_keys, $plugin->getCacheKeys());
         } else {
             $build[$entity_id] = $this->buildBlock($build[$entity_id]);
         }
         // Don't run in ::buildBlock() to ensure cache keys can be altered. If an
         // alter hook wants to modify the block contents, it can append another
         // #pre_render hook.
         $this->moduleHandler()->alter(array('block_view', "block_view_{$base_id}"), $build[$entity_id], $plugin);
     }
     return $build;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:BlockViewBuilder.php

示例2: testBlock

 /**
  * Tests that the block is cached with the correct contexts and tags.
  */
 public function testBlock()
 {
     $block = $this->drupalPlaceBlock('block_content:' . $this->entity->uuid());
     $build = $this->container->get('entity.manager')->getViewBuilder('block')->view($block, 'block');
     // Render the block.
     // @todo The request stack manipulation won't be necessary once
     //   https://www.drupal.org/node/2367555 is fixed and the
     //   corresponding $request->isMethodSafe() checks are removed from
     //   Drupal\Core\Render\Renderer.
     $request_stack = $this->container->get('request_stack');
     $request_stack->push(new Request());
     $this->container->get('renderer')->renderRoot($build);
     $request_stack->pop();
     // Expected keys, contexts, and tags for the block.
     // @see \Drupal\block\BlockViewBuilder::viewMultiple()
     $expected_block_cache_keys = ['entity_view', 'block', $block->id()];
     $expected_block_cache_contexts = ['languages:' . LanguageInterface::TYPE_INTERFACE, 'theme'];
     $expected_block_cache_tags = Cache::mergeTags(['block_view', 'rendered'], $block->getCacheTags(), $block->getPlugin()->getCacheTags());
     // Expected contexts and tags for the BlockContent entity.
     // @see \Drupal\Core\Entity\EntityViewBuilder::getBuildDefaults().
     $expected_entity_cache_contexts = ['theme'];
     $expected_entity_cache_tags = Cache::mergeTags(['block_content_view'], $this->entity->getCacheTags(), $this->getAdditionalCacheTagsForEntity($this->entity));
     // Verify that what was render cached matches the above expectations.
     $cid = $this->createCacheId($expected_block_cache_keys, $expected_block_cache_contexts);
     $redirected_cid = $this->createCacheId($expected_block_cache_keys, Cache::mergeContexts($expected_block_cache_contexts, $expected_entity_cache_contexts));
     $this->verifyRenderCache($cid, Cache::mergeTags($expected_block_cache_tags, $expected_entity_cache_tags), $cid !== $redirected_cid ? $redirected_cid : NULL);
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:30,代码来源:BlockContentCacheTagsTest.php

示例3: viewMultiple

 /**
  * {@inheritdoc}
  */
 public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL)
 {
     /** @var \Drupal\block\BlockInterface[] $entities */
     $build = array();
     foreach ($entities as $entity) {
         $entity_id = $entity->id();
         $plugin = $entity->getPlugin();
         $plugin_id = $plugin->getPluginId();
         $base_id = $plugin->getBaseId();
         $derivative_id = $plugin->getDerivativeId();
         $configuration = $plugin->getConfiguration();
         // Create the render array for the block as a whole.
         // @see template_preprocess_block().
         $build[$entity_id] = array('#theme' => 'block', '#attributes' => array(), '#contextual_links' => array('block' => array('route_parameters' => array('block' => $entity->id()))), '#weight' => $entity->get('weight'), '#configuration' => $configuration, '#plugin_id' => $plugin_id, '#base_plugin_id' => $base_id, '#derivative_plugin_id' => $derivative_id, '#id' => $entity->id(), '#block' => $entity);
         $build[$entity_id]['#configuration']['label'] = String::checkPlain($configuration['label']);
         // Set cache tags; these always need to be set, whether the block is
         // cacheable or not, so that the page cache is correctly informed.
         $build[$entity_id]['#cache']['tags'] = Cache::mergeTags($this->getCacheTag(), $entity->getCacheTag(), $plugin->getCacheTags());
         if ($plugin->isCacheable()) {
             $build[$entity_id]['#pre_render'][] = array($this, 'buildBlock');
             // Generic cache keys, with the block plugin's custom keys appended
             // (usually cache context keys like 'cache_context.user.roles').
             $default_cache_keys = array('entity_view', 'block', $entity->id(), $this->languageManager->getCurrentLanguage()->getId(), 'cache_context.theme');
             $max_age = $plugin->getCacheMaxAge();
             $build[$entity_id]['#cache'] += array('keys' => array_merge($default_cache_keys, $plugin->getCacheKeys()), 'expire' => $max_age === Cache::PERMANENT ? Cache::PERMANENT : REQUEST_TIME + $max_age);
         } else {
             $build[$entity_id] = $this->buildBlock($build[$entity_id]);
         }
         // Don't run in ::buildBlock() to ensure cache keys can be altered. If an
         // alter hook wants to modify the block contents, it can append another
         // #pre_render hook.
         $this->moduleHandler()->alter(array('block_view', "block_view_{$base_id}"), $build[$entity_id], $plugin);
     }
     return $build;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:38,代码来源:BlockViewBuilder.php

示例4: testCacheTags

 /**
  * Tests the bubbling of cache tags.
  */
 public function testCacheTags()
 {
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = $this->container->get('renderer');
     // Create the entity that will be commented upon.
     $commented_entity = entity_create('entity_test', array('name' => $this->randomMachineName()));
     $commented_entity->save();
     // Verify cache tags on the rendered entity before it has comments.
     $build = \Drupal::entityManager()->getViewBuilder('entity_test')->view($commented_entity);
     $renderer->renderRoot($build);
     $cache_context_tags = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($build['#cache']['contexts'])->getCacheTags();
     $expected_cache_tags = Cache::mergeTags($cache_context_tags, ['entity_test_view', 'entity_test:' . $commented_entity->id(), 'comment_list', 'config:core.entity_form_display.comment.comment.default', 'config:field.field.comment.comment.comment_body', 'config:field.field.entity_test.entity_test.comment', 'config:field.storage.comment.comment_body', 'config:user.settings']);
     sort($expected_cache_tags);
     $this->assertEqual($build['#cache']['tags'], $expected_cache_tags);
     // Create a comment on that entity. Comment loading requires that the uid
     // also exists in the {users} table.
     $user = $this->createUser();
     $user->save();
     $comment = entity_create('comment', array('subject' => 'Llama', 'comment_body' => array('value' => 'Llamas are cool!', 'format' => 'plain_text'), 'entity_id' => $commented_entity->id(), 'entity_type' => 'entity_test', 'field_name' => 'comment', 'comment_type' => 'comment', 'status' => CommentInterface::PUBLISHED, 'uid' => $user->id()));
     $comment->save();
     // Load commented entity so comment_count gets computed.
     // @todo Remove the $reset = TRUE parameter after
     //   https://www.drupal.org/node/597236 lands. It's a temporary work-around.
     $commented_entity = entity_load('entity_test', $commented_entity->id(), TRUE);
     // Verify cache tags on the rendered entity when it has comments.
     $build = \Drupal::entityManager()->getViewBuilder('entity_test')->view($commented_entity);
     $renderer->renderRoot($build);
     $cache_context_tags = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($build['#cache']['contexts'])->getCacheTags();
     $expected_cache_tags = Cache::mergeTags($cache_context_tags, ['entity_test_view', 'entity_test:' . $commented_entity->id(), 'comment_list', 'comment_view', 'comment:' . $comment->id(), 'config:filter.format.plain_text', 'user_view', 'user:2', 'config:core.entity_form_display.comment.comment.default', 'config:field.field.comment.comment.comment_body', 'config:field.field.entity_test.entity_test.comment', 'config:field.storage.comment.comment_body', 'config:user.settings']);
     sort($expected_cache_tags);
     $this->assertEqual($build['#cache']['tags'], $expected_cache_tags);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:35,代码来源:CommentDefaultFormatterCacheTagsTest.php

示例5: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = [];
     /** @var \Drupal\rng\Entity\EventType[] $event_types */
     foreach ($this->eventManager->getEventTypes() as $entity_type => $event_types) {
         $cache_tags = $this->entityManager->getDefinition($entity_type)->getListCacheTags();
         foreach ($event_types as $event_type) {
             $cache_tags = Cache::mergeTags($cache_tags, $event_type->getCacheTags());
         }
         // Only need one set of tasks task per entity type.
         if ($this->routeProvider->getRouteByName("entity.{$entity_type}.canonical")) {
             $event_default = "rng.event.{$entity_type}.event.default";
             $this->derivatives[$event_default] = array('title' => t('Event'), 'base_route' => "entity.{$entity_type}.canonical", 'route_name' => "rng.event.{$entity_type}.event", 'weight' => 30, 'cache_tags' => $cache_tags);
             $this->derivatives["rng.event.{$entity_type}.event.settings"] = array('title' => t('Settings'), 'route_name' => $this->derivatives[$event_default]['route_name'], 'parent_id' => 'rng.local_tasks:' . $event_default, 'weight' => 10, 'cache_tags' => $cache_tags);
             $this->derivatives["rng.event.{$entity_type}.event.access"] = array('title' => t('Access'), 'route_name' => "rng.event.{$entity_type}.access", 'parent_id' => 'rng.local_tasks:' . $event_default, 'weight' => 20, 'cache_tags' => $cache_tags);
             $this->derivatives["rng.event.{$entity_type}.event.messages"] = array('title' => t('Messages'), 'route_name' => "rng.event.{$entity_type}.messages", 'parent_id' => 'rng.local_tasks:' . $event_default, 'weight' => 30, 'cache_tags' => $cache_tags);
             $this->derivatives["rng.event.{$entity_type}.event.group.list"] = array('title' => t('Groups'), 'route_name' => "rng.event.{$entity_type}.group.list", 'parent_id' => 'rng.local_tasks:' . $event_default, 'weight' => 40, 'cache_tags' => $cache_tags);
             $this->derivatives["rng.event.{$entity_type}.register.type_list"] = array('route_name' => "rng.event.{$entity_type}.register.type_list", 'base_route' => "entity.{$entity_type}.canonical", 'title' => t('Register'), 'weight' => 40, 'cache_tags' => $cache_tags);
         }
     }
     foreach ($this->derivatives as &$entry) {
         $entry += $base_plugin_definition;
     }
     return parent::getDerivativeDefinitions($base_plugin_definition);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:28,代码来源:LocalTasks.php

示例6: buildRegions

 /**
  * #pre_render callback for building the regions.
  */
 public function buildRegions(array $build)
 {
     $cacheability = CacheableMetadata::createFromRenderArray($build)->addCacheableDependency($this);
     $contexts = $this->getContexts();
     foreach ($this->getRegionAssignments() as $region => $blocks) {
         if (!$blocks) {
             continue;
         }
         $region_name = Html::getClass("block-region-{$region}");
         $build[$region]['#prefix'] = '<div class="' . $region_name . '">';
         $build[$region]['#suffix'] = '</div>';
         /** @var \Drupal\Core\Block\BlockPluginInterface[] $blocks */
         $weight = 0;
         foreach ($blocks as $block_id => $block) {
             if ($block instanceof ContextAwarePluginInterface) {
                 $this->contextHandler()->applyContextMapping($block, $contexts);
             }
             $access = $block->access($this->account, TRUE);
             $cacheability->addCacheableDependency($access);
             if (!$access->isAllowed()) {
                 continue;
             }
             $block_build = ['#theme' => 'block', '#attributes' => [], '#weight' => $weight++, '#configuration' => $block->getConfiguration(), '#plugin_id' => $block->getPluginId(), '#base_plugin_id' => $block->getBaseId(), '#derivative_plugin_id' => $block->getDerivativeId(), '#block_plugin' => $block, '#pre_render' => [[$this, 'buildBlock']], '#cache' => ['keys' => ['page_manager_block_display', $this->id(), 'block', $block_id], 'tags' => Cache::mergeTags($this->getCacheTags(), $block->getCacheTags()), 'contexts' => $block->getCacheContexts(), 'max-age' => $block->getCacheMaxAge()]];
             // Merge the cacheability metadata of blocks into the page. This helps
             // to avoid cache redirects if the blocks have more cache contexts than
             // the page, which the page must respect as well.
             $cacheability->addCacheableDependency($block);
             $build[$region][$block_id] = $block_build;
         }
     }
     $build['#title'] = $this->renderPageTitle($this->configuration['page_title']);
     $cacheability->applyTo($build);
     return $build;
 }
开发者ID:jeroenos,项目名称:jeroenos_d8.mypressonline.com,代码行数:37,代码来源:PageBlockDisplayVariant.php

示例7: viewMultiple

 /**
  * {@inheritdoc}
  */
 public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL)
 {
     /** @var \Drupal\block\BlockInterface[] $entities */
     $build = array();
     foreach ($entities as $entity) {
         $entity_id = $entity->id();
         $plugin = $entity->getPlugin();
         $cache_tags = Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags());
         $cache_tags = Cache::mergeTags($cache_tags, $plugin->getCacheTags());
         // Create the render array for the block as a whole.
         // @see template_preprocess_block().
         $build[$entity_id] = array('#cache' => ['keys' => ['entity_view', 'block', $entity->id()], 'contexts' => Cache::mergeContexts($entity->getCacheContexts(), $plugin->getCacheContexts()), 'tags' => $cache_tags, 'max-age' => $plugin->getCacheMaxAge()], '#weight' => $entity->getWeight());
         // Allow altering of cacheability metadata or setting #create_placeholder.
         $this->moduleHandler->alter(['block_build', "block_build_" . $plugin->getBaseId()], $build[$entity_id], $plugin);
         if ($plugin instanceof MainContentBlockPluginInterface || $plugin instanceof TitleBlockPluginInterface) {
             // Immediately build a #pre_render-able block, since this block cannot
             // be built lazily.
             $build[$entity_id] += static::buildPreRenderableBlock($entity, $this->moduleHandler());
         } else {
             // Assign a #lazy_builder callback, which will generate a #pre_render-
             // able block lazily (when necessary).
             $build[$entity_id] += ['#lazy_builder' => [static::class . '::lazyBuilder', [$entity_id, $view_mode, $langcode]]];
         }
     }
     return $build;
 }
开发者ID:318io,项目名称:318-io,代码行数:29,代码来源:BlockViewBuilder.php

示例8: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $config = $this->config('system.site');
     // Display login form:
     $form['name'] = array('#type' => 'textfield', '#title' => $this->t('Username'), '#size' => 60, '#maxlength' => USERNAME_MAX_LENGTH, '#description' => $this->t('Enter your @s username.', array('@s' => $config->get('name'))), '#required' => TRUE, '#attributes' => array('autocorrect' => 'off', 'autocapitalize' => 'off', 'spellcheck' => 'false', 'autofocus' => 'autofocus'));
     $form['pass'] = array('#type' => 'password', '#title' => $this->t('Password'), '#size' => 60, '#description' => $this->t('Enter the password that accompanies your username.'), '#required' => TRUE);
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Log in'));
     $form['#validate'][] = '::validateName';
     $form['#validate'][] = '::validateAuthentication';
     $form['#validate'][] = '::validateFinal';
     $form['#cache']['tags'] = Cache::mergeTags(isset($form['#cache']['tags']) ? $form['#cache']['tags'] : [], $config->getCacheTags());
     return $form;
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:17,代码来源:UserLoginForm.php

示例9: invalidateTags

 /**
  * {@inheritdoc}
  */
 public function invalidateTags(array $tags)
 {
     // When either an extension (module/theme) is (un)installed, purge
     // everything.
     if (in_array('config:core.extension', $tags)) {
         // @todo Purge everything. Blocked on https://github.com/d8-contrib-modules/cloudflare/issues/16.
         return;
     }
     // Also invalidate the cache tags as hashes, to automatically also work for
     // responses that exceed CloudFlare's Cache-Tag header limit.
     $hashes = CloudFlareCacheTagHeaderGenerator::cacheTagsToHashes($tags);
     $tags = Cache::mergeTags($tags, $hashes);
     $this->purgeTags($tags);
 }
开发者ID:victorcpereira,项目名称:cloudflare,代码行数:17,代码来源:CacheTagsInvalidator.php

示例10: testCommentRss

 /**
  * Tests comments as part of an RSS feed.
  */
 function testCommentRss()
 {
     // Find comment in RSS feed.
     $this->drupalLogin($this->webUser);
     $this->postComment($this->node, $this->randomMachineName(), $this->randomMachineName());
     $this->drupalGet('rss.xml');
     $cache_contexts = ['languages:language_interface', 'theme', 'url.site', 'user.node_grants:view', 'user.permissions', 'timezone'];
     $this->assertCacheContexts($cache_contexts);
     $cache_context_tags = \Drupal::service('cache_contexts_manager')->convertTokensToKeys($cache_contexts)->getCacheTags();
     $this->assertCacheTags(Cache::mergeTags($cache_context_tags, ['config:views.view.frontpage', 'node:1', 'node_list', 'node_view', 'user:3']));
     $raw = '<comments>' . $this->node->url('canonical', array('fragment' => 'comments', 'absolute' => TRUE)) . '</comments>';
     $this->assertRaw($raw, 'Comments as part of RSS feed.');
     // Hide comments from RSS feed and check presence.
     $this->node->set('comment', CommentItemInterface::HIDDEN);
     $this->node->save();
     $this->drupalGet('rss.xml');
     $this->assertNoRaw($raw, 'Hidden comments is not a part of RSS feed.');
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:21,代码来源:CommentRssTest.php

示例11: assertViewsCacheTags

 /**
  * Asserts a view's result & output cache items' cache tags.
  *
  * @param \Drupal\views\ViewExecutable $view
  *   The view to test, must have caching enabled.
  * @param null|string[] $expected_results_cache
  *   NULL when expecting no results cache item, a set of cache tags expected
  *   to be set on the results cache item otherwise.
  * @param bool $views_caching_is_enabled
  *   Whether to expect an output cache item. If TRUE, the cache tags must
  *   match those in $expected_render_array_cache_tags.
  * @param string[] $expected_render_array_cache_tags
  *   A set of cache tags expected to be set on the built view's render array.
  *
  * @return array
  *   The render array
  */
 protected function assertViewsCacheTags(ViewExecutable $view, $expected_results_cache, $views_caching_is_enabled, array $expected_render_array_cache_tags)
 {
     $build = $view->preview();
     // Ensure the current request is a GET request so that render caching is
     // active for direct rendering of views, just like for actual requests.
     /** @var \Symfony\Component\HttpFoundation\RequestStack $request_stack */
     $request_stack = \Drupal::service('request_stack');
     $request_stack->push(new Request());
     \Drupal::service('renderer')->renderRoot($build);
     $request_stack->pop();
     // Render array cache tags.
     $this->pass('Checking render array cache tags.');
     sort($expected_render_array_cache_tags);
     $this->assertEqual($build['#cache']['tags'], $expected_render_array_cache_tags);
     if ($views_caching_is_enabled) {
         $this->pass('Checking Views results cache item cache tags.');
         /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache_plugin */
         $cache_plugin = $view->display_handler->getPlugin('cache');
         // Results cache.
         $results_cache_item = \Drupal::cache('data')->get($cache_plugin->generateResultsKey());
         if (is_array($expected_results_cache)) {
             $this->assertTrue($results_cache_item, 'Results cache item found.');
             if ($results_cache_item) {
                 sort($expected_results_cache);
                 $this->assertEqual($results_cache_item->tags, $expected_results_cache);
             }
         } else {
             $this->assertFalse($results_cache_item, 'Results cache item not found.');
         }
         // Output cache.
         $this->pass('Checking Views output cache item cache tags.');
         $output_cache_item = \Drupal::cache('render')->get($cache_plugin->generateOutputKey());
         if ($views_caching_is_enabled === TRUE) {
             $this->assertTrue($output_cache_item, 'Output cache item found.');
             if ($output_cache_item) {
                 $this->assertEqual($output_cache_item->tags, Cache::mergeTags($expected_render_array_cache_tags, ['rendered']));
             }
         } else {
             $this->assertFalse($output_cache_item, 'Output cache item not found.');
         }
     }
     $view->destroy();
     return $build;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:61,代码来源:AssertViewsCacheTagsTrait.php

示例12: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     $this->derivatives = [];
     /** @var \Drupal\rng\Entity\EventType[] $event_types */
     foreach ($this->eventManager->getEventTypes() as $entity_type => $event_types) {
         $cache_tags = $this->entityManager->getDefinition($entity_type)->getListCacheTags();
         foreach ($event_types as $event_type) {
             $cache_tags = Cache::mergeTags($cache_tags, $event_type->getCacheTags());
         }
         // Only need one set of actions per entity type.
         $this->derivatives["rng.event.{$entity_type}.event.access.reset"] = array('title' => $this->t('Reset/customize access rules'), 'route_name' => "rng.event.{$entity_type}.access.reset", 'class' => '\\Drupal\\rng\\Plugin\\Menu\\LocalAction\\ResetAccessRules', 'appears_on' => array("rng.event.{$entity_type}.access"), 'cache_tags' => $cache_tags);
         $this->derivatives["rng.event.{$entity_type}.event.message.add"] = array('title' => $this->t('Add message'), 'route_name' => "rng.event.{$entity_type}.messages.add", 'appears_on' => array("rng.event.{$entity_type}.messages"), 'cache_tags' => $cache_tags);
         $this->derivatives["rng.event.{$entity_type}.event.group.add"] = array('title' => $this->t('Add group'), 'route_name' => "rng.event.{$entity_type}.group.add", 'appears_on' => array("rng.event.{$entity_type}.group.list"), 'cache_tags' => $cache_tags);
     }
     foreach ($this->derivatives as &$entry) {
         $entry += $base_plugin_definition;
     }
     return $this->derivatives;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:22,代码来源:LocalActions.php

示例13: viewMultiple

 /**
  * {@inheritdoc}
  */
 public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL)
 {
     /** @var \Drupal\block\BlockInterface[] $entities */
     $build = array();
     foreach ($entities as $entity) {
         $entity_id = $entity->id();
         $plugin = $entity->getPlugin();
         $plugin_id = $plugin->getPluginId();
         $base_id = $plugin->getBaseId();
         $derivative_id = $plugin->getDerivativeId();
         $configuration = $plugin->getConfiguration();
         // Create the render array for the block as a whole.
         // @see template_preprocess_block().
         $build[$entity_id] = array('#theme' => 'block', '#attributes' => array(), '#contextual_links' => array('block' => array('route_parameters' => array('block' => $entity->id()))), '#weight' => $entity->getWeight(), '#configuration' => $configuration, '#plugin_id' => $plugin_id, '#base_plugin_id' => $base_id, '#derivative_plugin_id' => $derivative_id, '#id' => $entity->id(), '#cache' => ['keys' => ['entity_view', 'block', $entity->id()], 'contexts' => $plugin->getCacheContexts(), 'tags' => Cache::mergeTags($this->getCacheTags(), $entity->getCacheTags(), $plugin->getCacheTags()), 'max-age' => $plugin->getCacheMaxAge()], '#pre_render' => [[$this, 'buildBlock']], '#block' => $entity);
         $build[$entity_id]['#configuration']['label'] = SafeMarkup::checkPlain($configuration['label']);
         // Don't run in ::buildBlock() to ensure cache keys can be altered. If an
         // alter hook wants to modify the block contents, it can append another
         // #pre_render hook.
         $this->moduleHandler()->alter(array('block_view', "block_view_{$base_id}"), $build[$entity_id], $plugin);
     }
     return $build;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:25,代码来源:BlockViewBuilder.php

示例14: render

 /**
  * {@inheritdoc}
  */
 public function render(HtmlFragmentInterface $fragment, $status_code = 200)
 {
     // Converts the given HTML fragment which represents the main content region
     // of the page into a render array.
     $page_content['main'] = array('#markup' => $fragment->getContent());
     $page_content['#title'] = $fragment->getTitle();
     if ($fragment instanceof CacheableInterface) {
         $page_content['main']['#cache']['tags'] = $fragment->getCacheTags();
     }
     // Build the full page array by calling drupal_prepare_page(), which invokes
     // hook_page_build(). This adds the other regions to the page.
     $page_array = drupal_prepare_page($page_content);
     // Build the HtmlPage object.
     $page = new HtmlPage('', array(), $fragment->getTitle());
     $page = $this->preparePage($page, $page_array);
     $page->setBodyTop(drupal_render_root($page_array['page_top']));
     $page->setBodyBottom(drupal_render_root($page_array['page_bottom']));
     $page->setContent(drupal_render_root($page_array));
     $page->setStatusCode($status_code);
     drupal_process_attached($page_array);
     if (isset($page_array['page_top'])) {
         drupal_process_attached($page_array['page_top']);
     }
     if (isset($page_array['page_bottom'])) {
         drupal_process_attached($page_array['page_bottom']);
     }
     if ($fragment instanceof CacheableInterface) {
         // Persist cache tags associated with this page. Also associate the
         // "rendered" cache tag. This allows us to invalidate the entire render
         // cache, regardless of the cache bin.
         $cache_tags = Cache::mergeTags(isset($page_array['page_top']) ? $page_array['page_top']['#cache']['tags'] : [], $page_array['#cache']['tags'], isset($page_array['page_bottom']) ? $page_array['page_bottom']['#cache']['tags'] : [], ['rendered']);
         // Only keep unique cache tags. We need to prevent duplicates here already
         // rather than only in the cache layer, because they are also used by
         // reverse proxies (like Varnish), not only by Drupal's page cache.
         $page->setCacheTags(array_unique($cache_tags));
     }
     return $page;
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:41,代码来源:DefaultHtmlFragmentRenderer.php

示例15: getCacheTags

 /**
  * {@inheritdoc}
  */
 public function getCacheTags() {
   $tags = parent::getCacheTags();
   return Cache::mergeTags($tags, ['block_visibility_group:' . $this->id]);
 }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:7,代码来源:BlockVisibilityGroup.php


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