<?php


namespace App\Components\Forms;


use App\Model\Facades\GameFacade;
use App\Model\Translator;

class StudioFormFactory extends BaseFormFactory
{
    /** @var GameFacade */
    protected $gameFacade;

    public function __construct(Translator $translator, GameFacade $gameFacade)
    {
        parent::__construct($translator);
        $this->gameFacade = $gameFacade;
    }


    public function create() : BootstrapForm
    {
        $form = parent::create();
        $form->addText('name', 'Studio name:')
            ->addRule(BootstrapForm::FILLED, 'Please fill studio name.');
        $form->addSubmit('submit', 'Submit');

        return $form;
    }


    public function formSucceeded(BootstrapForm $form, $values)
    {
        $this->gameFacade->getStudioWriter()->createStudio($values->name);
    }
}