<?php

namespace App\Components\Forms;

use App\Model\Interfaces\IFormFactory;
use App\Model\Translator;

abstract class BaseFormFactory implements IFormFactory
{
    /** @var Translator */
    protected $translator;

    public function __construct(Translator $translator)
    {
        $this->translator = $translator;
    }

    /**
     * @return BootstrapForm
     */
    public function create() : BootstrapForm
    {
        $form = new BootstrapForm();
        $form->setTranslator($this->translator);
        $form->addProtection('Form expired, try it again please.');
        $form->onSuccess[] = array($this, 'formSucceeded');

        return $form;
    }
}