1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Encore\Admin\Grid\Displayers; |
4
|
|
|
|
5
|
|
|
use Encore\Admin\Admin; |
6
|
|
|
use Illuminate\Contracts\Support\Renderable; |
7
|
|
|
|
8
|
|
|
class Modal extends AbstractDisplayer |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
protected $renderable; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @param int $multiple |
|
|
|
|
17
|
|
|
* |
18
|
|
|
* @return string |
19
|
|
|
*/ |
20
|
|
|
protected function getLoadUrl() |
21
|
|
|
{ |
22
|
|
|
$renderable = str_replace('\\', '_', $this->renderable); |
23
|
|
|
|
24
|
|
|
return route('admin.handle-renderable', compact('renderable')); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
protected function addRenderableModalScript() |
28
|
|
|
{ |
29
|
|
|
$script = <<<SCRIPT |
30
|
|
|
(function () { |
31
|
|
|
var modal = $('.grid-modal'); |
32
|
|
|
|
33
|
|
|
modal.on('show.bs.modal', function (e) { |
34
|
|
|
var key = $(e.relatedTarget).data('key'); |
35
|
|
|
$.get('{$this->getLoadUrl()}'+'&key='+key, function (data) { |
36
|
|
|
modal.find('.modal-body').html(data); |
37
|
|
|
}); |
38
|
|
|
}) |
39
|
|
|
})(); |
40
|
|
|
SCRIPT; |
41
|
|
|
|
42
|
|
|
Admin::script($script); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function display($callback = null) |
46
|
|
|
{ |
47
|
|
|
if (func_num_args() == 2) { |
48
|
|
|
list($title, $callback) = func_get_args(); |
49
|
|
|
} elseif (func_num_args() == 1) { |
50
|
|
|
$title = $this->trans('title'); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
View Code Duplication |
if (is_subclass_of($callback, Renderable::class)) { |
|
|
|
|
54
|
|
|
$html = <<<HTML |
55
|
|
|
<div class="loading text-center"> |
56
|
|
|
<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i> |
57
|
|
|
</div> |
58
|
|
|
HTML; |
59
|
|
|
$this->renderable = $callback; |
60
|
|
|
$this->addRenderableModalScript(); |
61
|
|
|
} else { |
62
|
|
|
$callback = $callback->bindTo($this->row); |
63
|
|
|
$html = call_user_func_array($callback, [$this->row]); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
$key = $this->getKey().'-'.str_replace('.', '_', $this->getColumn()->getName()); |
67
|
|
|
|
68
|
|
|
return <<<EOT |
69
|
|
|
<span data-toggle="modal" data-target="#grid-modal-{$key}" data-key="{$this->getKey()}"> |
70
|
|
|
<a href="javascript:void(0)"><i class="fa fa-clone"></i> {$this->value}</a> |
71
|
|
|
</span> |
72
|
|
|
|
73
|
|
|
<div class="modal grid-modal" id="grid-modal-{$key}" tabindex="-1" role="dialog"> |
74
|
|
|
<div class="modal-dialog modal-lg" role="document"> |
75
|
|
|
<div class="modal-content"> |
76
|
|
|
<div class="modal-header"> |
77
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> |
78
|
|
|
<h4 class="modal-title">{$title}</h4> |
|
|
|
|
79
|
|
|
</div> |
80
|
|
|
<div class="modal-body"> |
81
|
|
|
{$html} |
82
|
|
|
</div> |
83
|
|
|
</div> |
84
|
|
|
</div> |
85
|
|
|
</div> |
86
|
|
|
|
87
|
|
|
EOT; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.