This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form.php
62 lines (52 loc) · 1.54 KB
/
Form.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 Revolution\ZendForm;
use Illuminate\Container\Container;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\HtmlString;
use Zend\Form\Form as ZendForm;
use Zend\View\Renderer\RendererInterface;
class Form extends ZendForm
{
/**
* @return RendererInterface
*
* @throws BindingResolutionException
*/
protected function getRenderer(): RendererInterface
{
return Container::getInstance()->make(RendererInterface::class);
}
/**
* @param string $helper
*
* @return HtmlString
*
* @throws BindingResolutionException
* @throws \BadMethodCallException
*/
public function render(string $helper = 'form'): HtmlString
{
$renderer = $this->getRenderer();
if (is_callable([$renderer, $helper])) {
return new HtmlString(call_user_func_array([$renderer, $helper], [$this]));
}
throw new \BadMethodCallException(sprintf('Method [%s] does not exist.', $helper));
}
/**
* @param string $method
* @param array $arguments
*
* @return mixed
*
* @throws BindingResolutionException
* @throws \BadMethodCallException
*/
public function __call($method, $arguments)
{
$renderer = $this->getRenderer();
if (is_callable([$renderer, $method])) {
return call_user_func_array([$renderer, $method], $arguments);
}
throw new \BadMethodCallException(sprintf('Method [%s] does not exist.', $method));
}
}