Skip to content

Instantly share code, notes, and snippets.

@Kcko
Created February 2, 2018 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kcko/d30606bb358b813d3c8e7b51f7e17f2d to your computer and use it in GitHub Desktop.
Save Kcko/d30606bb358b813d3c8e7b51f7e17f2d to your computer and use it in GitHub Desktop.
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);
});
}
}
{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