<?php

namespace KupShop\AdminBundle\Util;

use KupShop\CatalogBundle\Util\ProductsFilterSpecs;
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;

class ProductListFilter
{
    public function applyFilter($filter, $qb)
    {
        if (!is_array($filter)) {
            return;
        }

        $productsFilterSpecs = ServiceContainer::getService(ProductsFilterSpecs::class);
        $specs = $productsFilterSpecs->getSpecs($filter);
        if ($specs) {
            $qb->andWhere($specs);
        }
    }
}
