protected function getQuery()
    {
        $locationService = $this->get( "ezpublish.api.repository" )->getLocationService();
        $limitToRootLocation = $this->getConfigResolver()->getParameter( 'limit_to_rootlocation', 'nova_ezseo' );
        $excludes        = $this->getConfigResolver()->getParameter( 'sitemap_excludes', 'nova_ezseo' );
        $query           = new Query();
        $criterion[]     = new Criterion\Visibility( Criterion\Visibility::VISIBLE );
        if ( true === $limitToRootLocation ) {
            $criterion[]     = new Criterion\Subtree( $this->getRootLocation()->pathString );
        }
        foreach ( $excludes['contentTypeIdentifiers'] as $contentTypeIdentifier )
        {
            $criterion[] = new Criterion\LogicalNot( new Criterion\ContentTypeIdentifier( $contentTypeIdentifier ) );
        }
        foreach ( $excludes['subtrees'] as $locationId )
        {
            $excludedLocation = $this->getRepository()->sudo(
                function () use ($locationService, $locationId) {
                    try
                    {
                        return $locationService->loadLocation( $locationId );
                    } catch (\Exception $e) {
                        return false;
                    }
                }
            );
            if ($excludedLocation) {
                $criterion[]      = new Criterion\LogicalNot( new Criterion\Subtree( $excludedLocation->pathString ) );
            }
        }
        foreach ( $excludes['locations'] as $locationId )
        {
            $criterion[] = new Criterion\LogicalNot( new Criterion\LocationId( $locationId ) );
        }

        $query->query = new Criterion\LogicalAnd( $criterion );
        $query->sortClauses = [ new SortClause\DatePublished( Query::SORT_DESC) ];

        return $query;
    }