jruzafa
1/27/2016 - 11:54 AM

Ticket - M2 - Devopensource_Tickets

Ticket - M2 - Devopensource_Tickets

<?php

namespace Devopensource\Tickets\Controller;

abstract class Ticket extends \Magento\Framework\App\Action\Action
{

    protected $customerSession;

    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Customer\Model\Session $customerSession
    )
    {

        $this->customerSession = $customerSession;
        parent::__construct($context);

    }

    public function dispatch(\Magento\Framework\App\RequestInterface $request)

    {

        if (!$this->customerSession->authenticate()) {

            $this->_actionFlag->set('', 'no-dispatch', true);

            if (!$this->customerSession->getBeforeUrl()) {

                $this->customerSession->setBeforeUrl($this->_redirect->getRefererUrl());

            }

        }

        return parent::dispatch($request);

    }
}