public function getScopedQuery($entity)
    {
        $query = $this->getRepository()->getQuery();

        foreach ($this->_scopes as $key => $value) {
            if (is_numeric($key)) {
                $key = $value;
                $value = $entity->$key;
            }

            $query->where($key, '=', $value);
        }

        return $query;
    }