/
Renderer.php
62 lines (52 loc) · 1.37 KB
/
Renderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace Concrete\Core\Express\Form;
use Concrete\Core\Entity\Express\Entry;
use Concrete\Core\Express\Form\Context\ContextInterface;
class Renderer
{
/**
* @var \Concrete\Core\Express\Form\Context\ContextInterface
*/
protected $context;
/**
* The form that's going to be rendered.
*
* @var \Concrete\Core\Express\Form\FormInterface
*/
protected $form;
public function __construct(ContextInterface $context, FormInterface $form)
{
$this->context = $context;
$this->form = $form;
$this->context->setForm($form);
}
/**
* @return \Concrete\Core\Express\Form\Context\ContextInterface
*/
public function getContext()
{
return $this->context;
}
/**
* @param \Concrete\Core\Express\Form\Context\ContextInterface $context
*/
public function setContext($context)
{
$this->context = $context;
}
/**
* @param \Concrete\Core\Entity\Express\Entry|null $entry
*
* @throws \Exception
*/
public function render(Entry $entry = null)
{
if ($entry) {
$this->context->setEntry($entry);
}
/** @var \Concrete\Core\Form\Control\View $view */
$view = $this->form->getControlView($this->context);
$renderer = $view->getControlRenderer();
$renderer->render();
}
}