<?php

declare(strict_types=1);

namespace KupShop\CatalogElasticBundle\Resources\upgrade;

class SearchUpgrade extends \UpgradeNew
{
    public function check_createSearchSection()
    {
        return findModule(\Modules::COMPONENTS)
            && sqlQueryBuilder()->select('COUNT(*)')
                ->from('sections')
                ->andWhere('id = -1')
                ->execute()
                ->fetchOne() === 0;
    }

    /** Create section for Search with id = -1 */
    public function upgrade_createSearchSection()
    {
        sqlQueryBuilder()->insert('sections')
            ->directValues([
                'id' => -1,
                'name' => 'Vyhledávání',
                'figure' => 'Y',
                'filter_url' => 'vyhledavani',
                'behaviour' => 2,
            ])->execute();
    }
}
