<?php

class ApplicationControllerFactory {

	private $site_base;
	private $post;
	private $sessionWrapper;

	public function __construct(SessionWrapper $sessionWrapper){
		$this->setSiteBase(SITE_BASE);
		$this->setPost($_POST);
		$this->sessionWrapper = $sessionWrapper;
	}

	public function setSiteBase($site_base){
		$this->site_base = $site_base;
	}

	public function setPost(array $post){
		$this->post = $post;
	}

	public function getInstance($className){
		$linkFactory = new LinkFactory($this->site_base);

		/** @var ApplicationController $controller */
		$controller =  new $className();

		$mainPage = new MainPage();
		$mainPage->setTitle("Test de l'API S2low");
		$mainPage->setLinkFactory($linkFactory);
		$controller->setMainPage($mainPage);

		$controller->setLinkFactory($linkFactory);
		$controller->setPost($this->post);
		$controller->setSessionWrapper($this->sessionWrapper);

		return $controller;
	}

}