Created
February 2, 2018 11:31
-
-
Save Kcko/d30606bb358b813d3c8e7b51f7e17f2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PollControl extends Control | |
{ | |
public function __construct(array $info) | |
{ | |
$this->info = $info; | |
} | |
} | |
interface IPollControlFactory | |
{ | |
/** | |
* @param array $info | |
* @return PollControl | |
*/ | |
function create(array $info); | |
} | |
class PollPresenter extends Presenter | |
{ | |
/** @var PollFactory @inject */ | |
public $pollFactory; | |
private $pollInfos = []; | |
public function actionDefault() | |
{ | |
$this->pollInfos = $this->pollRepository->getAllPaired(); // array [id => info] | |
} | |
public function renderDefault() | |
{ | |
$this->template->polls = $this->pollInfos; | |
} | |
protected function createComponentPoll() | |
{ | |
return new Multiplier(function($id) { | |
$pollInfo = $this->pollInfos[$id]; | |
return $this->pollFactory->create($pollInfo); | |
}); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{foreach $polls as $id => $poll} | |
<h2>Anketa {$poll->name}</h2> | |
{control poll-$id} | |
{/foreach} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment