cache = $treeCache; $this->keyGenerator = $keyGenerator; } /** * @ORM\PostUpdate() * @ORM\PostPersist() * @ORM\PostRemove() */ public function invalidate(DBElement $element, LifecycleEventArgs $event) { //If an element was changed, then invalidate all cached trees with this element class if ($element instanceof StructuralDBElement) { $secure_class_name = str_replace('\\', '_', \get_class($element)); $this->cache->invalidateTags([$secure_class_name]); } //If a user change, then invalidate all cached trees for him if ($element instanceof User) { $tag = $this->keyGenerator->generateKey($element); $this->cache->invalidateTags([$tag]); } /* If any group change, then invalidate all cached trees. Users Permissions can be inherited from groups, so a change in any group can cause big permisssion changes for users. So to be sure, invalidate all trees */ if ($element instanceof Group) { $tag = 'groups'; $this->cache->invalidateTags([$tag]); } } }