src/Identity/Doctrine/ORM/QueryExtension/DeletedExtension.php
protected function apply(QueryBuilder $queryBuilder, string $resourceClass)
    {
        if (!in_array(Deletable::class, class_implements($resourceClass), true)) {
            return;
        }

        $token = $this->tokenStorage->getToken();

        if ($token) {
            $user = $token->getUser();

            if ($user instanceof User) {
                if (in_array($user->getIdentity()->getType(), [Identity::SYSTEM, Identity::STAFF], true)) {
                    $request = $this->requestStack->getCurrentRequest();
                    $deleted = $request->query->get('deleted', 'false');
                    $rootAlias = $queryBuilder->getRootAliases()[0];

                    switch ($deleted) {
                        case 'true':
                            $queryBuilder->andWhere($rootAlias . '.deletedAt IS NOT NULL');
                            break;

                        case 'false':
                            $queryBuilder->andWhere($rootAlias . '.deletedAt IS NULL');
                            break;

                        case 'null':
                            break;
                    }

                    return;
                }
            }
        }

        $rootAlias = $queryBuilder->getRootAliases()[0];
        $queryBuilder->andWhere($rootAlias.'.deletedAt IS NULL');
    }
protected function apply(QueryBuilder $queryBuilder, string $resourceClass)
    {
        if (!in_array(Deletable::class, class_implements($resourceClass), true)) {
            return;
        }

        $token = $this->tokenStorage->getToken();

        if ($token) {
            $user = $token->getUser();

            if ($user instanceof User) {
                if (in_array($user->getIdentity()->getType(), [Identity::SYSTEM, Identity::STAFF], true)) {
                    $request = $this->requestStack->getCurrentRequest();
                    $deleted = $request->query->get('deleted', 'false');
                    $rootAlias = $queryBuilder->getRootAliases()[0];

                    switch ($deleted) {
                        case 'true':
                            $queryBuilder->andWhere($rootAlias . '.deletedAt IS NOT NULL');
                            break;

                        case 'false':
                            $queryBuilder->andWhere($rootAlias . '.deletedAt IS NULL');
                            break;

                        case 'null':
                            break;
                    }

                    return;
                }
            }
        }

        $rootAlias = $queryBuilder->getRootAliases()[0];
        $queryBuilder->andWhere($rootAlias.'.deletedAt IS NULL');
    }
Apply condition

@param \Doctrine\ORM\QueryBuilder $queryBuilder
@param string $resourceClass