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

PHP Cache\CacheBackendInterface类代码示例

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

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



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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->keyValueFactory = $this->prophesize(KeyValueFactoryInterface::class);
     $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
     $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class);
     $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);
     $this->fieldDefinitionListener = new FieldDefinitionListener($this->entityTypeManager->reveal(), $this->entityFieldManager->reveal(), $this->keyValueFactory->reveal(), $this->cacheBackend->reveal());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:12,代码来源:FieldDefinitionListenerTest.php


示例2: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
     $this->moduleHandler->getImplementations('entity_type_build')->willReturn([]);
     $this->moduleHandler->alter('entity_type', Argument::type('array'))->willReturn(NULL);
     $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);
     $this->translationManager = $this->prophesize(TranslationInterface::class);
     $this->entityTypeManager = new TestEntityTypeManager(new \ArrayObject(), $this->moduleHandler->reveal(), $this->cacheBackend->reveal(), $this->translationManager->reveal(), $this->getClassResolverStub());
     $this->discovery = $this->prophesize(DiscoveryInterface::class);
     $this->entityTypeManager->setDiscovery($this->discovery->reveal());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:15,代码来源:EntityTypeManagerTest.php


示例3: loadBaseDefinitions

 /**
  * Loads the base country definitions.
  *
  * @return array
  */
 protected function loadBaseDefinitions()
 {
     if (!empty($this->baseDefinitions)) {
         return $this->baseDefinitions;
     }
     $cache_key = 'address.countries.base';
     if ($cached = $this->cache->get($cache_key)) {
         $this->baseDefinitions = $cached->data;
     } else {
         $this->baseDefinitions = json_decode(file_get_contents($this->definitionPath . 'base.json'), TRUE);
         $this->cache->set($cache_key, $this->baseDefinitions, CacheBackendInterface::CACHE_PERMANENT, ['countries']);
     }
     return $this->baseDefinitions;
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:19,代码来源:CountryRepository.php


示例4: user

 /**
  * User object.
  *
  * @return \Drupal\moodle\Sql\User
  */
 public function user()
 {
     // Static cache of already retrieved user data.
     $data =& drupal_static(__METHOD__, array());
     $user_cid = "moodle-user:{$this->user->id()}";
     // If we do not have this user id in the static cache, check {cache_data}.
     if (!isset($data[$user_cid])) {
         $cache = $this->cacheBackend->get($user_cid);
         if ($cache && $cache->data && isset($cache->data[$user_cid])) {
             $data[$user_cid] = $cache->data[$user_cid];
         }
     }
     // If nothing in the cache then retrieve it from the database.
     if (!isset($data[$user_cid])) {
         $user = new User();
         $this->query();
         $this->addFields();
         $statement = $this->query->execute();
         $statement->setFetchMode(\PDO::FETCH_INTO, $user);
         $data[$user_cid] = $statement->fetch();
         // Store the results for a day.
         $this->cacheBackend->set($user_cid, $data, REQUEST_TIME + 86400);
     }
     return $data[$user_cid];
 }
开发者ID:bonrita,项目名称:moodle,代码行数:30,代码来源:CurrentUser.php


示例5: generate

 /**
  * {@inheritdoc}
  *
  * Cached by role, invalidated whenever permissions change.
  */
 public function generate(AccountInterface $account)
 {
     // User 1 is the super user, and can always access all permissions. Use a
     // different, unique identifier for the hash.
     if ($account->id() == 1) {
         return $this->hash('is-super-user');
     }
     $sorted_roles = $account->getRoles();
     sort($sorted_roles);
     $role_list = implode(',', $sorted_roles);
     $cid = "user_permissions_hash:{$role_list}";
     if ($static_cache = $this->static->get($cid)) {
         return $static_cache->data;
     } else {
         $tags = Cache::buildTags('config:user.role', $sorted_roles, '.');
         if ($cache = $this->cache->get($cid)) {
             $permissions_hash = $cache->data;
         } else {
             $permissions_hash = $this->doGenerate($sorted_roles);
             $this->cache->set($cid, $permissions_hash, Cache::PERMANENT, $tags);
         }
         $this->static->set($cid, $permissions_hash, Cache::PERMANENT, $tags);
     }
     return $permissions_hash;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:30,代码来源:PermissionsHashGenerator.php


示例6: testDestruct

 /**
  * Tests the destruct method.
  *
  * @covers ::destruct
  */
 public function testDestruct()
 {
     $this->libraryDiscoveryParser->expects($this->once())->method('buildByExtension')->with('test')->will($this->returnValue($this->libraryData));
     $lock_key = 'library_info:Drupal\\Core\\Cache\\CacheCollector';
     $this->lock->expects($this->once())->method('acquire')->with($lock_key)->will($this->returnValue(TRUE));
     $this->cache->expects($this->exactly(2))->method('get')->with('library_info')->will($this->returnValue(FALSE));
     $this->cache->expects($this->once())->method('set')->with('library_info', array('test' => $this->libraryData), Cache::PERMANENT, array('library_info'));
     $this->lock->expects($this->once())->method('release')->with($lock_key);
     // This should get data and persist the key.
     $this->libraryDiscoveryCollector->get('test');
     $this->libraryDiscoveryCollector->destruct();
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:17,代码来源:LibraryDiscoveryCollectorTest.php


示例7: generate

 /**
  * {@inheritdoc}
  *
  * Cached by role, invalidated whenever permissions change.
  */
 public function generate(AccountInterface $account)
 {
     $sorted_roles = $account->getRoles();
     sort($sorted_roles);
     $role_list = implode(',', $sorted_roles);
     if ($cache = $this->cache->get("user_permissions_hash:{$role_list}")) {
         $permissions_hash = $cache->data;
     } else {
         $permissions_hash = $this->doGenerate($sorted_roles);
         $this->cache->set("user_permissions_hash:{$role_list}", $permissions_hash, Cache::PERMANENT, array('user_role' => $sorted_roles));
     }
     return $permissions_hash;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:18,代码来源:PermissionsHash.php


示例8: generate

 /**
  * {@inheritdoc}
  *
  * Cached by role, invalidated whenever permissions change.
  */
 public function generate(AccountInterface $account)
 {
     $sorted_roles = $account->getRoles();
     sort($sorted_roles);
     $role_list = implode(',', $sorted_roles);
     if ($cache = $this->cache->get("user_permissions_hash:{$role_list}")) {
         $permissions_hash = $cache->data;
     } else {
         $permissions_hash = $this->doGenerate($sorted_roles);
         $tags = Cache::buildTags('config:user.role', $sorted_roles, '.');
         $this->cache->set("user_permissions_hash:{$role_list}", $permissions_hash, Cache::PERMANENT, $tags);
     }
     return $permissions_hash;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:19,代码来源:PermissionsHashGenerator.php


示例9: onFieldDefinitionDelete

 /**
  * {@inheritdoc}
  */
 public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition)
 {
     $entity_type_id = $field_definition->getTargetEntityTypeId();
     $bundle = $field_definition->getTargetBundle();
     $field_name = $field_definition->getName();
     // Notify the storage about the field deletion.
     $this->entityTypeManager->getStorage($entity_type_id)->onFieldDefinitionDelete($field_definition);
     // Unset the bundle from the bundle field map key value collection.
     $bundle_field_map = $this->keyValueFactory->get('entity.definitions.bundle_field_map')->get($entity_type_id);
     unset($bundle_field_map[$field_name]['bundles'][$bundle]);
     if (empty($bundle_field_map[$field_name]['bundles'])) {
         // If there are no bundles left, remove the field from the map.
         unset($bundle_field_map[$field_name]);
     }
     $this->keyValueFactory->get('entity.definitions.bundle_field_map')->set($entity_type_id, $bundle_field_map);
     // Delete the cache entry.
     $this->cacheBackend->delete('entity_field_map');
     // If the field map is initialized, update it as well, so that calls to it
     // do not have to rebuild it again.
     if ($field_map = $this->entityFieldManager->getFieldMap()) {
         unset($field_map[$entity_type_id][$field_name]['bundles'][$bundle]);
         if (empty($field_map[$entity_type_id][$field_name]['bundles'])) {
             unset($field_map[$entity_type_id][$field_name]);
         }
         $this->entityFieldManager->setFieldMap($field_map);
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:30,代码来源:FieldDefinitionListener.php


示例10: testDisable

 /**
  * @covers ::disable
  * @depends testSetStatus
  */
 public function testDisable()
 {
     $this->cacheBackend->expects($this->once())->method('invalidateTags')->with(array($this->entityTypeId . ':' . $this->id));
     $this->entity->setStatus(TRUE);
     $this->assertSame($this->entity, $this->entity->disable());
     $this->assertFalse($this->entity->status());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:ConfigEntityBaseUnitTest.php


示例11: testGetInfo

 /**
  * Tests the getInfo method.
  *
  * @covers ::getInfo
  * @covers ::buildInfo
  *
  * @dataProvider providerTestGetInfo
  */
 public function testGetInfo($type, $expected_info, $element_info, callable $alter_callback = NULL)
 {
     $this->moduleHandler->expects($this->once())->method('invokeAll')->with('element_info')->will($this->returnValue($element_info));
     $this->moduleHandler->expects($this->once())->method('alter')->with('element_info', $this->anything())->will($this->returnCallback($alter_callback ?: function ($info) {
         return $info;
     }));
     $this->themeManager->expects($this->once())->method('getActiveTheme')->willReturn(new ActiveTheme(['name' => 'test']));
     $this->themeManager->expects($this->once())->method('alter')->with('element_info', $this->anything())->will($this->returnCallback($alter_callback ?: function ($info) {
         return $info;
     }));
     $this->cache->expects($this->at(0))->method('get')->with('element_info_build:test')->will($this->returnValue(FALSE));
     $this->cache->expects($this->at(1))->method('get')->with('element_info')->will($this->returnValue(FALSE));
     $this->cache->expects($this->at(2))->method('set')->with('element_info');
     $this->cache->expects($this->at(3))->method('set')->with('element_info_build:test');
     $this->assertEquals($expected_info, $this->elementInfo->getInfo($type));
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:24,代码来源:ElementInfoManagerTest.php


示例12: testDeleteTagsPropagation

 /**
  * Test that the delete tags operation is propagated to all backends
  * in the chain.
  */
 public function testDeleteTagsPropagation()
 {
     // Create two cache entries with the same tag and tag value.
     $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:2'));
     $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:2'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two cache items were created in all backends.');
     // Invalidate test_tag of value 1. This should invalidate both entries.
     $this->chain->invalidateTags(array('test_tag:2'));
     $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two caches removed from all backends after clearing a cache tag.');
     // Create two cache entries with the same tag and an array tag value.
     $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:1'));
     $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:1'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two cache items were created in all backends.');
     // Invalidate test_tag of value 1. This should invalidate both entries.
     $this->chain->invalidateTags(array('test_tag:1'));
     $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two caches removed from all backends after clearing a cache tag.');
     // Create three cache entries with a mix of tags and tag values.
     $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:1'));
     $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:2'));
     $this->chain->set('test_cid_clear3', 'foo', Cache::PERMANENT, array('test_tag_foo:3'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->firstBackend->get('test_cid_clear3') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear3') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear3'), 'Three cached items were created in all backends.');
     $this->chain->invalidateTags(array('test_tag_foo:3'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Cached items not matching the tag were not cleared from any of the backends.');
     $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear3') && $this->secondBackend->get('test_cid_clear3') && $this->thirdBackend->get('test_cid_clear3'), 'Cached item matching the tag was removed from all backends.');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:29,代码来源:BackendChainImplementationUnitTest.php


示例13: onRequestSent

 /**
  * Responds after a request has finished, but before it is sent to the client.
  *
  * @param \Guzzle\Common\Event $event
  *   The Guzzle event object.
  */
 public function onRequestSent(Event $event)
 {
     $request = $event['request'];
     $response = $event['response'];
     // Handle permanent redirects by setting the redirected URL so that the
     // client can grab it quickly.
     $redirect = FALSE;
     $url = $old_url = $request->getUrl();
     if ($previous_response = $response->getPreviousResponse()) {
         if ($previous_response->getStatusCode() == 301 && ($location = $previous_response->getLocation())) {
             $response->getParams()->set('feeds.redirect', $location);
             $redirect = TRUE;
             $url = $request->getUrl();
         }
     }
     $cache_hit = $response->getStatusCode() == 304;
     if ($redirect) {
         // Delete the old cache entry.
         $this->cacheBackend->delete($this->getCacheKey($old_url));
         // Not sure if the repeated requests are smart enough to find the
         // redirect, so cache the old URL with the new response.
         static::$downloadCache[$old_url] = $response;
     }
     if ($redirect || !$cache_hit) {
         $cache = new \stdClass();
         $cache->headers = array_change_key_case($response->getHeaders()->toArray());
         // @todo We should only cache for certain status codes.
         $cache->code = $response->getStatusCode();
         $this->cacheBackend->set($this->getCacheKey($url), $cache);
     }
     // Set in-page download cache.
     static::$downloadCache[$url] = $response;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:39,代码来源:CachePlugin.php


示例14: setCachedDefinitions

 /**
  * Sets a cache of plugin definitions for the decorated discovery class.
  *
  * @param array $definitions
  *   List of definitions to store in cache.
  */
 protected function setCachedDefinitions($definitions)
 {
     if ($this->cacheBackend) {
         $this->cacheBackend->set($this->cacheKey, $definitions, Cache::PERMANENT, $this->cacheTags);
     }
     $this->definitions = $definitions;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:13,代码来源:DefaultPluginManager.php


示例15: testGetAliasByPathUncachedMissWithAlias

 /**
  * Tests the getAliasByPath cache with an unpreloaded path with alias.
  *
  * @covers ::getAliasByPath
  * @covers ::writeCache
  */
 public function testGetAliasByPathUncachedMissWithAlias()
 {
     $path_part1 = $this->randomMachineName();
     $path_part2 = $this->randomMachineName();
     $path = '/' . $path_part1 . '/' . $path_part2;
     $cached_path = $this->randomMachineName();
     $cached_no_alias_path = $this->randomMachineName();
     $cached_alias = $this->randomMachineName();
     $new_alias = $this->randomMachineName();
     $language = $this->setUpCurrentLanguage();
     $cached_paths = array($language->getId() => array($cached_path, $cached_no_alias_path));
     $this->cache->expects($this->once())->method('get')->with($this->cacheKey)->will($this->returnValue((object) array('data' => $cached_paths)));
     // Simulate a request so that the preloaded paths are fetched.
     $this->aliasManager->setCacheKey($this->path);
     $this->aliasWhitelist->expects($this->any())->method('get')->with($path_part1)->will($this->returnValue(TRUE));
     $this->aliasStorage->expects($this->once())->method('preloadPathAlias')->with($cached_paths[$language->getId()], $language->getId())->will($this->returnValue(array($cached_path => $cached_alias)));
     $this->aliasStorage->expects($this->once())->method('lookupPathAlias')->with($path, $language->getId())->will($this->returnValue($new_alias));
     $this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
     // Call it twice to test the static cache.
     $this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
     // There is already a cache entry, so this should not write out to the
     // cache.
     $this->cache->expects($this->never())->method('set');
     $this->aliasManager->writeCache();
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:31,代码来源:AliasManagerTest.php


示例16: getImplementationInfo

 /**
  * Provides information about modules' implementations of a hook.
  *
  * @param string $hook
  *   The name of the hook (e.g. "help" or "menu").
  *
  * @return mixed[]
  *   An array whose keys are the names of the modules which are implementing
  *   this hook and whose values are either a string identifying a file in
  *   which the implementation is to be found, or FALSE, if the implementation
  *   is in the module file.
  */
 protected function getImplementationInfo($hook)
 {
     if (!isset($this->implementations)) {
         $this->implementations = array();
         $this->verified = array();
         if ($cache = $this->cacheBackend->get('module_implements')) {
             $this->implementations = $cache->data;
         }
     }
     if (!isset($this->implementations[$hook])) {
         // The hook is not cached, so ensure that whether or not it has
         // implementations, the cache is updated at the end of the request.
         $this->cacheNeedsWriting = TRUE;
         // Discover implementations.
         $this->implementations[$hook] = $this->buildImplementationInfo($hook);
         // Implementations are always "verified" as part of the discovery.
         $this->verified[$hook] = TRUE;
     } elseif (!isset($this->verified[$hook])) {
         if (!$this->verifyImplementations($this->implementations[$hook], $hook)) {
             // One or more of the implementations did not exist and need to be
             // removed in the cache.
             $this->cacheNeedsWriting = TRUE;
         }
         $this->verified[$hook] = TRUE;
     }
     return $this->implementations[$hook];
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:39,代码来源:ModuleHandler.php


示例17: testBuildTreeWithoutParameters

 /**
  * Tests buildTree with simple menu_name and no parameters.
  */
 public function testBuildTreeWithoutParameters()
 {
     $language = new Language(array('id' => 'en'));
     $this->languageManager->expects($this->any())->method('getCurrentLanguage')->will($this->returnValue($language));
     // Setup query and the query result.
     $query = $this->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
     $this->entityQueryFactory->expects($this->once())->method('get')->with('menu_link')->will($this->returnValue($query));
     $query->expects($this->once())->method('condition')->with('menu_name', 'test_menu');
     $query->expects($this->once())->method('execute')->will($this->returnValue(array(1, 2, 3)));
     $storage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $base = array('access' => TRUE, 'weight' => 0, 'title' => 'title');
     $menu_link = $base + array('mlid' => 1, 'p1' => 3, 'p2' => 2, 'p3' => 1);
     $links[1] = $menu_link;
     $menu_link = $base + array('mlid' => 3, 'p1' => 3, 'depth' => 1);
     $links[3] = $menu_link;
     $menu_link = $base + array('mlid' => 2, 'p1' => 3, 'p2' => 2, 'depth' => 2);
     $links[2] = $menu_link;
     $storage->expects($this->once())->method('loadMultiple')->with(array(1, 2, 3))->will($this->returnValue($links));
     $this->menuTree->setStorage($storage);
     // Ensure that static/non static caching works.
     // First setup no working caching.
     $this->cacheBackend->expects($this->at(0))->method('get')->with('links:test_menu:tree-data:en:35786c7117b4e38d0f169239752ce71158266ae2f6e4aa230fbbb87bd699c0e3')->will($this->returnValue(FALSE));
     $this->cacheBackend->expects($this->at(1))->method('set')->with('links:test_menu:tree-data:en:35786c7117b4e38d0f169239752ce71158266ae2f6e4aa230fbbb87bd699c0e3', $this->anything(), Cache::PERMANENT, array('menu' => 'test_menu'));
     // Ensure that the static caching triggered.
     $this->cacheBackend->expects($this->exactly(1))->method('get');
     $this->menuTree->buildTree('test_menu');
     $this->menuTree->buildTree('test_menu');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:31,代码来源:MenuTreeTest.php


示例18: testDeleteNothing

 /**
  * @covers ::delete()
  * @covers ::doDelete()
  */
 public function testDeleteNothing()
 {
     $this->moduleHandler->expects($this->never())->method($this->anything());
     $this->configFactory->expects($this->never())->method('get');
     $this->cacheBackend->expects($this->never())->method('invalidateTags');
     $this->entityStorage->delete(array());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:11,代码来源:ConfigEntityStorageTest.php


示例19: loadTreeData

 /**
  * {@inheritdoc}
  */
 public function loadTreeData($menu_name, MenuTreeParameters $parameters)
 {
     // Build the cache ID; sort 'expanded' and 'conditions' to prevent duplicate
     // cache items.
     sort($parameters->expandedParents);
     asort($parameters->conditions);
     $tree_cid = "tree-data:{$menu_name}:" . serialize($parameters);
     $cache = $this->menuCacheBackend->get($tree_cid);
     if ($cache && isset($cache->data)) {
         $data = $cache->data;
         // Cache the definitions in memory so they don't need to be loaded again.
         $this->definitions += $data['definitions'];
         unset($data['definitions']);
     } else {
         $links = $this->loadLinks($menu_name, $parameters);
         $data['tree'] = $this->doBuildTreeData($links, $parameters->activeTrail, $parameters->minDepth);
         $data['definitions'] = array();
         $data['route_names'] = $this->collectRoutesAndDefinitions($data['tree'], $data['definitions']);
         $this->menuCacheBackend->set($tree_cid, $data, Cache::PERMANENT, ['config:system.menu.' . $menu_name]);
         // The definitions were already added to $this->definitions in
         // $this->doBuildTreeData()
         unset($data['definitions']);
     }
     return $data;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:28,代码来源:MenuTreeStorage.php


示例20: testGetAllBundleInfo

 /**
  * Tests the getAllBundleInfo() method.
  *
  * @covers ::getAllBundleInfo
  */
 public function testGetAllBundleInfo()
 {
     $this->moduleHandler->invokeAll('entity_bundle_info')->willReturn([]);
     $this->moduleHandler->alter('entity_bundle_info', Argument::type('array'))->willReturn(NULL);
     $apple = $this->prophesize(EntityTypeInterface::class);
     $apple->getLabel()->willReturn('Apple');
     $apple->getBundleOf()->willReturn(NULL);
     $banana = $this->prophesize(EntityTypeInterface::class);
     $banana->getLabel()->willReturn('Banana');
     $banana->getBundleOf()->willReturn(NULL);
     $this->setUpEntityTypeDefinitions(['apple' => $apple, 'banana' => $banana]);
     $this->cacheBackend->get('entity_bundle_info:en')->willReturn(FALSE);
     $this->cacheBackend->set('entity_bundle_info:en', Argument::any(), Cache::PERMANENT, ['entity_types', 'entity_bundles'])->will(function () {
         $this->get('entity_bundle_info:en')->willReturn((object) ['data' => 'cached data'])->shouldBeCalled();
     })->shouldBeCalled();
     $this->cacheTagsInvalidator->invalidateTags(['entity_bundles'])->shouldBeCalled();
     $this->typedDataManager->clearCachedDefinitions()->shouldBeCalled();
     $expected = ['apple' => ['apple' => ['label' => 'Apple']], 'banana' => ['banana' => ['label' => 'Banana']]];
     $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
     $this->assertSame($expected, $bundle_info);
     $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
     $this->assertSame($expected, $bundle_info);
     $this->entityTypeBundleInfo->clearCachedBundles();
     $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
     $this->assertSame('cached data', $bundle_info);
 }
开发者ID:vinodpanicker,项目名称:drupal-under-the-hood,代码行数:31,代码来源:EntityTypeBundleInfoTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Cache\CacheTagsInvalidatorInterface类代码示例发布时间:2022-05-23
下一篇:
PHP Cache\Cache类代码示例发布时间: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