コード例 #1
0
ファイル: EntityUnitTest.php プロジェクト: ddrozdik/dmaps
 /**
  * @covers ::postSave
  */
 public function testPostSave()
 {
     $this->cacheTagsInvalidator->expects($this->at(0))->method('invalidateTags')->with(array($this->entityTypeId . '_list'));
     $this->cacheTagsInvalidator->expects($this->at(1))->method('invalidateTags')->with(array($this->entityTypeId . ':' . $this->values['id'], $this->entityTypeId . '_list'));
     // This method is internal, so check for errors on calling it only.
     $storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
     // A creation should trigger the invalidation of the "list" cache tag.
     $this->entity->postSave($storage, FALSE);
     // An update should trigger the invalidation of both the "list" and the
     // "own" cache tags.
     $this->entity->postSave($storage, TRUE);
 }
コード例 #2
0
ファイル: MenuLink.php プロジェクト: alnutile/drunatra
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Check the has_children status of the parent.
     $storage->updateParentalStatus($this);
     // Entity::postSave() calls Entity::invalidateTagsOnSave(), which only
     // handles the regular cases. The MenuLink entity has two special cases.
     $cache_tags = array();
     // Case 1: a newly created menu link is *also* added to a menu, so we must
     // invalidate the associated menu's cache tag.
     if (!$update) {
         $cache_tags = $this->getCacheTag();
     }
     // Case 2: a menu link may be moved from one menu to another; the original
     // menu's cache tag must also be invalidated.
     if (isset($this->original) && $this->menu_name != $this->original->menu_name) {
         $cache_tags = NestedArray::mergeDeep($cache_tags, $this->original->getCacheTag());
     }
     Cache::invalidateTags($cache_tags);
     // Also clear the menu system static caches.
     menu_reset_static_cache();
     // Track which menu items are expanded.
     _menu_update_expanded_menus();
 }