<?php

namespace ArcaSolutions\SearchBundle\Entity\Sorters;

use Elastica\Query;

class ViewSorter extends BaseSorter
{
    protected static $name = "popular";

    public static function getSubscribedEvents()
    {
        return [
            'search.global'   => 'register',
            'popular.deal'    => 'register',
            'popular.article' => 'register',
            'popular.blog'    => 'register',
            'popular.event'   => 'register'
        ];
    }

    public function sort(Query $query)
    {
        $query->setSort([
            'views' => ['order' => 'desc'],
            'level' => ['order' => 'asc'],
        ]);
    }
}
