<?php

declare(strict_types=1);

namespace KupShop\AdminBundle\Admin\Tabs;

use KupShop\AdminBundle\Admin\WindowTab;
use Symfony\Component\ErrorHandler\Debug;

class CodeEditorTab extends WindowTab
{
    protected $title = 'flapCodeEditor';

    protected $template = 'window/tabs/codeEditorTab.tpl';

    public static function getTypes(): array
    {
        return [
            'cleaning' => 4,
        ];
    }

    public function getLabel()
    {
        return 'Editor kódu';
    }

    public function handleExec(): void
    {
        $data = str_replace('<?php', '', getVal('code_exec'));
        if (!empty($data)) {
            set_exception_handler(null);
            Debug::enable();
            eval($data);
            exit;
        }
    }
}
