<?php

namespace DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Action\View;

use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Factory\ViewActionFactory;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\Request\Request;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\Service\Container\Abstraction\ServiceContainerInterface;
use DropshippingExportFreeVendor\WPDesk\Library\DropshippingExport\Infrastructure\View\Abstraction\Displayable;
/**
 * Class ViewAction, show view based on request.
 *
 * @package WPDesk\Library\DropshippingExport\Action\View
 */
class ViewAction implements Displayable
{
    /**
     * @var Request
     */
    private $request;
    /**
     * @var ViewActionFactory
     */
    private $factory;
    /**
     * @var ServiceContainerInterface
     */
    private $service_container;
    public function __construct(Request $request, ViewActionFactory $factory, ServiceContainerInterface $service_container)
    {
        $this->request = $request;
        $this->factory = $factory;
        $this->service_container = $service_container;
    }
    public function show()
    {
        $view = $this->factory->create_from_request($this->request);
        $this->service_container->register($view);
        $view->show();
    }
}
