1 | <?php |
||
24 | class GridViewHelper |
||
25 | { |
||
26 | /** |
||
27 | * A list of grid aliases |
||
28 | * @var array |
||
29 | */ |
||
30 | private static $aliases = [ |
||
31 | 'column' => [ |
||
32 | 'attribute' => AttributeColumn::class, |
||
33 | 'raw' => CallbackColumn::class, |
||
34 | 'callback' => CallbackColumn::class, |
||
35 | 'actions' => ActionsColumn::class, |
||
36 | 'view' => ViewColumn::class, |
||
37 | ], |
||
38 | 'formatter' => [ |
||
39 | 'email' => EmailFormatter::class, |
||
40 | 'image' => ImageFormatter::class, |
||
41 | 'text' => TextFormatter::class, |
||
42 | 'url' => UrlFormatter::class, |
||
43 | 'raw' => RawFormatter::class, |
||
44 | ], |
||
45 | 'filter' => [ |
||
46 | 'text' => TextFilter::class, |
||
47 | 'dropdown' => DropdownFilter::class, |
||
48 | ], |
||
49 | 'renderer' => [ |
||
50 | 'default' => DefaultRenderer::class, |
||
51 | ], |
||
52 | 'action' => [ |
||
53 | 'delete' => DeleteAction::class, |
||
54 | 'update' => EditAction::class, |
||
55 | 'edit' => EditAction::class, |
||
56 | 'show' => ShowAction::class, |
||
57 | 'view' => ShowAction::class, |
||
58 | 'action' => Action::class, |
||
59 | ] |
||
60 | ]; |
||
61 | |||
62 | private function __construct() {} |
||
63 | |||
64 | /** |
||
65 | * Useful in case you want to register a new alias for your project |
||
66 | * @param string $context |
||
67 | * @param string $alias |
||
68 | * @param string $aliasTo |
||
69 | */ |
||
70 | public static function registerAlias(string $context, string $alias, string $aliasTo) |
||
74 | |||
75 | /** |
||
76 | * Allows to resolve class name by its alias |
||
77 | * @param string $context |
||
78 | * @param string $alias |
||
79 | * @return mixed |
||
80 | */ |
||
81 | public static function resolveAlias(string $context, string $alias) |
||
85 | |||
86 | /** |
||
87 | * Allows to convert options array to html string |
||
88 | * @param array $htmlOptions |
||
89 | * @param array $context - context is variables, which are allowed to use when property value calculated dynamically |
||
90 | * @return string |
||
91 | */ |
||
92 | public static function htmlOptionsToString(array $htmlOptions, array $context = []) : string |
||
111 | |||
112 | /** |
||
113 | * Allows to make column title by it key or attribute name |
||
114 | * @param string|int $key |
||
115 | * @return string |
||
116 | */ |
||
117 | public static function columnTitle($key) : string |
||
141 | |||
142 | /** |
||
143 | * Helper for internal purposes |
||
144 | * @param $id |
||
145 | * @param $component |
||
146 | * @return string |
||
147 | */ |
||
148 | public static function gridIdFormatter($id, $component) |
||
156 | |||
157 | /** |
||
158 | * Generates page url with all requested params from request |
||
159 | * @param $gridId |
||
160 | * @param $page |
||
161 | */ |
||
162 | public static function pageUrl($gridId, $page) |
||
166 | } |
||
167 |