Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
resultview.php
1<?php
9
12
18Class ResultView
19{
20 const Title = 'title';
21 const Draw = 'draw';
22 const Filter = 'filter';
23 const FilterModifier = 'filter-modifier';
24 const ColumnModifier = 'column-modifier';
25
27 protected $connector;
28
30 protected $callbacks;
31
33 protected $nav;
34
40 public function __construct(Base $connector)
41 {
42 $this->connector = $connector;
43 }
44
53 public function setCallback($name, $callable)
54 {
55 if (!is_callable($callable))
56 {
57 throw new ArgumentException('Parameter \'callable\' should be callable.');
58 }
59
60 $this->callbacks[$name] = $callable;
61
62 return $this;
63 }
64
65 protected function runCallback($name, array $arguments = [])
66 {
67 if (!isset($this->callbacks[$name]))
68 {
69 return null;
70 }
71
72 return call_user_func_array($this->callbacks[$name], $arguments);
73 }
74
80 public function getTitle()
81 {
82 return $this->runCallback(self::Title) ?: $this->connector->getName();
83 }
84
91 public function modifyFilter(array &$filter)
92 {
93 $this->runCallback(self::FilterModifier, [&$filter]);
94 }
95
102 public function modifyColumns(array &$columns)
103 {
104 $this->runCallback(self::ColumnModifier, [&$columns]);
105 }
106
113 public function setNav(PageNavigation $nav = null)
114 {
115 $this->nav = $nav;
116 return $this;
117 }
118
124 public function getNav()
125 {
126 return $this->nav;
127 }
128
134 public function hasNav()
135 {
136 return !empty($this->nav);
137 }
138
144 public function onFilter()
145 {
146 $this->runCallback(self::Filter);
147 }
148
155 public function onDraw(array &$raw)
156 {
157 $this->runCallback(self::Draw, [&$raw]);
158 }
159}
modifyFilter(array &$filter)
__construct(Base $connector)
setCallback($name, $callable)
setNav(PageNavigation $nav=null)
runCallback($name, array $arguments=[])
modifyColumns(array &$columns)