protected function setWhere(QueryBuilder $query, $contentType, array $options)
    {
        $where = $query->expr()->andX()
                        ->add($query->expr()->eq('contenttype', ':contenttype'));

        // Set any required WHERE
        if (isset($options['contentid']) || isset($options['id'])) {
            if (isset($options['contentid'])) {
                $where->add($query->expr()->eq('contentid', ':contentid'));
            }

            if (isset($options['id'])) {
                $tableName = $this->getTableName();
                $where->add($query->expr()->eq("$tableName.id", ':logid'));
            }
        }

        $query->where($where)
            ->setParameters([
                ':contenttype' => $contentType,
                ':contentid'   => isset($options['contentid']) ? $options['contentid'] : null,
                ':logid'       => isset($options['id']) ? $options['id'] : null,
            ]);
    }