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

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

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

            if (in_array($user->getIdentity()->getType(), [Identity::SYSTEM, Identity::STAFF], true)) {
                return;
            }
        }

        $rootAlias = $queryBuilder->getRootAliases()[0];
        $queryBuilder
            ->andWhere($rootAlias.'.enabled = :ds_security_enabled')
            ->setParameter('ds_security_enabled', 1);
    }
protected function apply(QueryBuilder $queryBuilder, string $resourceClass)
    {
        if (!in_array(Enableable::class, class_implements($resourceClass), true)) {
            return;
        }

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

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

            if (in_array($user->getIdentity()->getType(), [Identity::SYSTEM, Identity::STAFF], true)) {
                return;
            }
        }

        $rootAlias = $queryBuilder->getRootAliases()[0];
        $queryBuilder
            ->andWhere($rootAlias.'.enabled = :ds_security_enabled')
            ->setParameter('ds_security_enabled', 1);
    }
Apply condition

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