<?php

namespace KupShop\SaveFormsBundle\Admin\menu;

use KupShop\KupShopBundle\Config;

class FormsMenu extends \Menu
{
    protected $template = 'menu/forms.tpl';

    public function get_vars()
    {
        $vars = parent::get_vars();

        $types = sqlFetchAll(sqlQueryBuilder()->select('DISTINCT type')->from('save_forms')->execute(), ['type' => 'type']);
        $forms = Config::get()['Modules']['forms'];
        $types = array_map(function ($t) use ($forms) { return $forms[$t]['title'] ?? $t; }, $types);
        $vars['types'] = $types ?? [];

        return $vars;
    }
}

return FormsMenu::class;
