<?php
/**
 * Event triggered when user is redirected on form submit
 * allows modifing the response that is send to the user
 *
 * Use VisualM\FormBundle\Helper\Event\FormEvents::ON_REDIRECT_RESPONSE
 * to attach a listener
 *
 * @author Elze Kool <info@visualmedia.nl>
 */

namespace VisualM\FormBundle\Helper\Event;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpFoundation\Response;
use VisualM\FormBundle\Entity\FormEntry as FormEntryEntity;

/**
 * Event called after populating the form builder
 * allows modifing the form just before it is about to be
 * rendered
 *
 * Use VisualM\FormBundle\Helper\Event\FormEvents::AFTER_POPULATE_BUILDER
 * to attach a listener
 *
 * @author Elze Kool <info@visualmedia.nl>
 */
class OnRedirectResponseEvent extends Event
{
    /**
     * Response
     * @var Response|null
     */
    protected $response;

    /**
     * Form Entry Entity
     * @var FormEntryEntity
     */
    protected $formEntryEntity;

    /**
     * Constructor
     *
     * @param Response        $response        Response
     * @param FormEntryEntity $formEntryEntity Form Entity
     */
    public function __construct(Response $response, FormEntryEntity $formEntryEntity = null)
    {
        $this->response = $response;
        $this->formEntryEntity = $formEntryEntity;
    }

    /**
     * Get Response
     *
     * @return Response|null Response
     **/
    public function getResponse()
    {
        return $this->response;
    }

    /**
     * Set Response
     *
     * @param Response|null $response Response
     **/
    public function setResponse(Response $response = null)
    {
        $this->response = $response;
    }

    /**
     * Get Form Entry Entity
     *
     * @return FormEntryEntity
     */
    public function getFormEntryEntity()
    {
        return $this->formEntryEntity;
    }



}