public function afterCommit(TransactionEvent $event) {
    if ($event->getPhase() == TransactionEvent::AFTER_COMMIT) {
      // remove temporary permissions
      $permissionManager = $this->getPermissionManager();
      foreach ($this->tempPermissions as $permission) {
        $permissionManager->removeTempPermission($permission);
      }
    }
  }