@@ -6,17 +6,17 @@ |
||
6 | 6 | |
7 | 7 | abstract class BaseDataProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Should return total amount of rows |
|
11 | - * @param GridViewRequest $request |
|
12 | - * @return int |
|
13 | - */ |
|
14 | - abstract public function getCount(GridViewRequest $request) : int; |
|
9 | + /** |
|
10 | + * Should return total amount of rows |
|
11 | + * @param GridViewRequest $request |
|
12 | + * @return int |
|
13 | + */ |
|
14 | + abstract public function getCount(GridViewRequest $request) : int; |
|
15 | 15 | |
16 | - /** |
|
17 | - * Should return a list of data for current page |
|
18 | - * @param GridViewRequest $request |
|
19 | - * @return mixed |
|
20 | - */ |
|
21 | - abstract public function getData(GridViewRequest $request); |
|
16 | + /** |
|
17 | + * Should return a list of data for current page |
|
18 | + * @param GridViewRequest $request |
|
19 | + * @return mixed |
|
20 | + */ |
|
21 | + abstract public function getData(GridViewRequest $request); |
|
22 | 22 | } |
23 | 23 | \ No newline at end of file |
@@ -6,74 +6,74 @@ |
||
6 | 6 | |
7 | 7 | class ArrayDataProvider extends BaseDataProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - private $data; |
|
9 | + /** |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + private $data; |
|
13 | 13 | |
14 | - public function __construct(array $data) |
|
15 | - { |
|
16 | - $this->data = $data; |
|
17 | - } |
|
14 | + public function __construct(array $data) |
|
15 | + { |
|
16 | + $this->data = $data; |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * @param GridViewRequest $request |
|
21 | - * @return array |
|
22 | - */ |
|
23 | - protected function processData(GridViewRequest $request) : array |
|
24 | - { |
|
25 | - if (empty($this->data)) { |
|
26 | - return []; |
|
27 | - } |
|
19 | + /** |
|
20 | + * @param GridViewRequest $request |
|
21 | + * @return array |
|
22 | + */ |
|
23 | + protected function processData(GridViewRequest $request) : array |
|
24 | + { |
|
25 | + if (empty($this->data)) { |
|
26 | + return []; |
|
27 | + } |
|
28 | 28 | |
29 | - $tmp = collect($this->data); |
|
29 | + $tmp = collect($this->data); |
|
30 | 30 | |
31 | - if (!empty($request->filters)) { |
|
32 | - $tmp = $tmp->filter(function($item) use ($request) { |
|
33 | - foreach ($request->filters as $filterKey => $filterValue) { |
|
31 | + if (!empty($request->filters)) { |
|
32 | + $tmp = $tmp->filter(function($item) use ($request) { |
|
33 | + foreach ($request->filters as $filterKey => $filterValue) { |
|
34 | 34 | |
35 | - if (!isset($item[$filterKey])) { |
|
36 | - return false; |
|
37 | - } |
|
35 | + if (!isset($item[$filterKey])) { |
|
36 | + return false; |
|
37 | + } |
|
38 | 38 | |
39 | - if (strpos($item[$filterKey], $filterValue) === false) { |
|
40 | - return false; |
|
41 | - } |
|
42 | - } |
|
39 | + if (strpos($item[$filterKey], $filterValue) === false) { |
|
40 | + return false; |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - return true; |
|
45 | - }); |
|
46 | - } |
|
44 | + return true; |
|
45 | + }); |
|
46 | + } |
|
47 | 47 | |
48 | - if (!empty($request->sortColumn)) { |
|
49 | - $tmp = $tmp->sortBy( |
|
50 | - $request->sortColumn, |
|
51 | - SORT_REGULAR, |
|
52 | - $request->sortOrder == 'DESC' |
|
53 | - ); |
|
54 | - } |
|
48 | + if (!empty($request->sortColumn)) { |
|
49 | + $tmp = $tmp->sortBy( |
|
50 | + $request->sortColumn, |
|
51 | + SORT_REGULAR, |
|
52 | + $request->sortOrder == 'DESC' |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - return $tmp->values()->all(); |
|
57 | - } |
|
56 | + return $tmp->values()->all(); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * @inheritdoc |
|
61 | - */ |
|
62 | - public function getCount(GridViewRequest $request) : int |
|
63 | - { |
|
64 | - return count($this->processData($request)); |
|
65 | - } |
|
59 | + /** |
|
60 | + * @inheritdoc |
|
61 | + */ |
|
62 | + public function getCount(GridViewRequest $request) : int |
|
63 | + { |
|
64 | + return count($this->processData($request)); |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * @inheritdoc |
|
69 | - */ |
|
70 | - public function getData(GridViewRequest $request) |
|
71 | - { |
|
72 | - $tmp = $this->processData($request); |
|
67 | + /** |
|
68 | + * @inheritdoc |
|
69 | + */ |
|
70 | + public function getData(GridViewRequest $request) |
|
71 | + { |
|
72 | + $tmp = $this->processData($request); |
|
73 | 73 | |
74 | - return array_splice( |
|
75 | - $tmp, |
|
76 | - ($request->page -1) * $request->perPage, $request->perPage |
|
77 | - ); |
|
78 | - } |
|
74 | + return array_splice( |
|
75 | + $tmp, |
|
76 | + ($request->page -1) * $request->perPage, $request->perPage |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -73,7 +73,7 @@ |
||
73 | 73 | |
74 | 74 | return array_splice( |
75 | 75 | $tmp, |
76 | - ($request->page -1) * $request->perPage, $request->perPage |
|
76 | + ($request->page - 1) * $request->perPage, $request->perPage |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | } |
80 | 80 | \ No newline at end of file |
@@ -19,7 +19,7 @@ |
||
19 | 19 | |
20 | 20 | require_once __DIR__ . '/functions.php'; |
21 | 21 | |
22 | - \Blade::directive('grid', function ($expression) { |
|
22 | + \Blade::directive('grid', function($expression) { |
|
23 | 23 | return "<?php echo grid($expression) ?>"; |
24 | 24 | }); |
25 | 25 |
@@ -19,17 +19,17 @@ |
||
19 | 19 | |
20 | 20 | require_once __DIR__ . '/functions.php'; |
21 | 21 | |
22 | - \Blade::directive('grid', function ($expression) { |
|
23 | - return "<?php echo grid($expression) ?>"; |
|
24 | - }); |
|
22 | + \Blade::directive('grid', function ($expression) { |
|
23 | + return "<?php echo grid($expression) ?>"; |
|
24 | + }); |
|
25 | 25 | |
26 | - $this->publishes([ |
|
27 | - __DIR__ . '/../public' => 'public/vendor/grid-view', |
|
28 | - ], 'public'); |
|
26 | + $this->publishes([ |
|
27 | + __DIR__ . '/../public' => 'public/vendor/grid-view', |
|
28 | + ], 'public'); |
|
29 | 29 | |
30 | - if (!File::isDirectory(public_path('vendor/grid-view'))) { |
|
31 | - Artisan::call('vendor:publish', ['--tag' => 'public', '--force' => '']); |
|
32 | - } |
|
30 | + if (!File::isDirectory(public_path('vendor/grid-view'))) { |
|
31 | + Artisan::call('vendor:publish', ['--tag' => 'public', '--force' => '']); |
|
32 | + } |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function register() |
@@ -7,5 +7,5 @@ |
||
7 | 7 | * @throws \Woo\GridView\Exceptions\GridViewConfigException |
8 | 8 | */ |
9 | 9 | function grid(array $config) { |
10 | - return (new \Woo\GridView\GridView($config))->render(); |
|
10 | + return (new \Woo\GridView\GridView($config))->render(); |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -7,88 +7,88 @@ |
||
7 | 7 | |
8 | 8 | trait Configurable |
9 | 9 | { |
10 | - /** |
|
11 | - * Allows to load config into object properties |
|
12 | - * @param array $config |
|
13 | - * @throws GridViewConfigException |
|
14 | - */ |
|
15 | - public function loadConfig(array $config) |
|
16 | - { |
|
17 | - foreach ($config as $key => $value) { |
|
18 | - |
|
19 | - if (property_exists($this, $key)) { |
|
20 | - $this->$key = $value; |
|
21 | - } |
|
22 | - } |
|
23 | - |
|
24 | - $this->testConfig(); |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Should specify tests |
|
29 | - * @return array |
|
30 | - */ |
|
31 | - abstract protected function configTests() : array; |
|
32 | - |
|
33 | - /** |
|
34 | - * Allows to test attributes and types in config |
|
35 | - * @throws GridViewConfigException |
|
36 | - */ |
|
37 | - protected function testConfig() |
|
38 | - { |
|
39 | - foreach ($this->configTests() as $property => $tests) { |
|
40 | - |
|
41 | - if (!property_exists($this, $property)) { |
|
42 | - throw new GridViewConfigException( |
|
43 | - 'Unable to test ' . get_class($this) . ': property ' . $property . ' does not exist' |
|
44 | - ); |
|
45 | - } |
|
46 | - |
|
47 | - $testPassed = true; |
|
48 | - $testMessage = 'Validation failed'; |
|
49 | - |
|
50 | - foreach (explode('|', $tests) as $test) { |
|
51 | - |
|
52 | - switch ($test) { |
|
53 | - case 'int': |
|
54 | - $testPassed = is_numeric($this->$property); |
|
55 | - $testMessage = 'Property should be numeric'; |
|
56 | - break; |
|
57 | - |
|
58 | - case 'string': |
|
59 | - $testPassed = is_string($this->$property); |
|
60 | - $testMessage = 'Property should be a string'; |
|
61 | - break; |
|
62 | - |
|
63 | - case 'array': |
|
64 | - $testPassed = is_array($this->$property); |
|
65 | - $testMessage = 'Property should be an array'; |
|
66 | - break; |
|
67 | - |
|
68 | - case 'closure': |
|
69 | - $testPassed = $this->$property instanceof Closure; |
|
70 | - $testMessage = 'Property should be a valid callback (Closure instance)'; |
|
71 | - break; |
|
72 | - |
|
73 | - case 'boolean': |
|
74 | - $testPassed = is_bool($this->$property); |
|
75 | - $testMessage = 'Property should be boolean'; |
|
76 | - break; |
|
77 | - |
|
78 | - case 'any': |
|
79 | - break; |
|
80 | - |
|
81 | - default: |
|
82 | - $testPassed = $testPassed || is_a($this->$property, $test) || is_subclass_of($this->$property, $test); |
|
83 | - $testMessage = 'Property should be ' . $test . ' instance/class reference, check ' . $property; |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - if (!$testPassed) { |
|
88 | - throw new GridViewConfigException( |
|
89 | - 'Tests ' . $tests . ' has failed on ' . get_class($this) . '::' . $property . ': ' . $testMessage |
|
90 | - ); |
|
91 | - } |
|
92 | - } |
|
93 | - } |
|
10 | + /** |
|
11 | + * Allows to load config into object properties |
|
12 | + * @param array $config |
|
13 | + * @throws GridViewConfigException |
|
14 | + */ |
|
15 | + public function loadConfig(array $config) |
|
16 | + { |
|
17 | + foreach ($config as $key => $value) { |
|
18 | + |
|
19 | + if (property_exists($this, $key)) { |
|
20 | + $this->$key = $value; |
|
21 | + } |
|
22 | + } |
|
23 | + |
|
24 | + $this->testConfig(); |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Should specify tests |
|
29 | + * @return array |
|
30 | + */ |
|
31 | + abstract protected function configTests() : array; |
|
32 | + |
|
33 | + /** |
|
34 | + * Allows to test attributes and types in config |
|
35 | + * @throws GridViewConfigException |
|
36 | + */ |
|
37 | + protected function testConfig() |
|
38 | + { |
|
39 | + foreach ($this->configTests() as $property => $tests) { |
|
40 | + |
|
41 | + if (!property_exists($this, $property)) { |
|
42 | + throw new GridViewConfigException( |
|
43 | + 'Unable to test ' . get_class($this) . ': property ' . $property . ' does not exist' |
|
44 | + ); |
|
45 | + } |
|
46 | + |
|
47 | + $testPassed = true; |
|
48 | + $testMessage = 'Validation failed'; |
|
49 | + |
|
50 | + foreach (explode('|', $tests) as $test) { |
|
51 | + |
|
52 | + switch ($test) { |
|
53 | + case 'int': |
|
54 | + $testPassed = is_numeric($this->$property); |
|
55 | + $testMessage = 'Property should be numeric'; |
|
56 | + break; |
|
57 | + |
|
58 | + case 'string': |
|
59 | + $testPassed = is_string($this->$property); |
|
60 | + $testMessage = 'Property should be a string'; |
|
61 | + break; |
|
62 | + |
|
63 | + case 'array': |
|
64 | + $testPassed = is_array($this->$property); |
|
65 | + $testMessage = 'Property should be an array'; |
|
66 | + break; |
|
67 | + |
|
68 | + case 'closure': |
|
69 | + $testPassed = $this->$property instanceof Closure; |
|
70 | + $testMessage = 'Property should be a valid callback (Closure instance)'; |
|
71 | + break; |
|
72 | + |
|
73 | + case 'boolean': |
|
74 | + $testPassed = is_bool($this->$property); |
|
75 | + $testMessage = 'Property should be boolean'; |
|
76 | + break; |
|
77 | + |
|
78 | + case 'any': |
|
79 | + break; |
|
80 | + |
|
81 | + default: |
|
82 | + $testPassed = $testPassed || is_a($this->$property, $test) || is_subclass_of($this->$property, $test); |
|
83 | + $testMessage = 'Property should be ' . $test . ' instance/class reference, check ' . $property; |
|
84 | + } |
|
85 | + } |
|
86 | + |
|
87 | + if (!$testPassed) { |
|
88 | + throw new GridViewConfigException( |
|
89 | + 'Tests ' . $tests . ' has failed on ' . get_class($this) . '::' . $property . ': ' . $testMessage |
|
90 | + ); |
|
91 | + } |
|
92 | + } |
|
93 | + } |
|
94 | 94 | } |
95 | 95 | \ No newline at end of file |
@@ -22,134 +22,134 @@ |
||
22 | 22 | |
23 | 23 | class GridViewHelper |
24 | 24 | { |
25 | - /** |
|
26 | - * A list of grid aliases |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - private static $aliases = [ |
|
30 | - 'column' => [ |
|
31 | - 'attribute' => AttributeColumn::class, |
|
32 | - 'raw' => CallbackColumn::class, |
|
33 | - 'callback' => CallbackColumn::class, |
|
34 | - 'actions' => ActionsColumn::class, |
|
35 | - 'view' => ViewColumn::class, |
|
36 | - ], |
|
37 | - 'formatter' => [ |
|
38 | - 'email' => EmailFormatter::class, |
|
39 | - 'image' => ImageFormatter::class, |
|
40 | - 'text' => TextFormatter::class, |
|
41 | - 'url' => UrlFormatter::class, |
|
42 | - 'raw' => RawFormatter::class, |
|
43 | - ], |
|
44 | - 'filter' => [ |
|
45 | - 'text' => TextFilter::class, |
|
46 | - 'dropdown' => DropdownFilter::class, |
|
47 | - ], |
|
48 | - 'renderer' => [ |
|
49 | - 'default' => DefaultRenderer::class, |
|
50 | - ], |
|
51 | - 'action' => [ |
|
52 | - 'delete' => DeleteAction::class, |
|
53 | - 'update' => EditAction::class, |
|
54 | - 'edit' => EditAction::class, |
|
55 | - 'show' => ShowAction::class, |
|
56 | - 'view' => ShowAction::class, |
|
57 | - 'action' => Action::class, |
|
58 | - ] |
|
59 | - ]; |
|
60 | - |
|
61 | - private function __construct() {} |
|
62 | - |
|
63 | - /** |
|
64 | - * Useful in case you want to register a new alias for your project |
|
65 | - * @param string $context |
|
66 | - * @param string $alias |
|
67 | - * @param string $aliasTo |
|
68 | - */ |
|
69 | - public static function registerAlias(string $context, string $alias, string $aliasTo) |
|
70 | - { |
|
71 | - self::$aliases[$context][$alias] = $aliasTo; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Allows to resolve class name by its alias |
|
76 | - * @param string $context |
|
77 | - * @param string $alias |
|
78 | - * @return mixed |
|
79 | - */ |
|
80 | - public static function resolveAlias(string $context, string $alias) |
|
81 | - { |
|
82 | - return self::$aliases[$context][$alias] ?? $alias; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Allows to convert options array to html string |
|
87 | - * @param array $htmlOptions |
|
88 | - * @param array $context - context is variables, which are allowed to use when property value calculated dynamically |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public static function htmlOptionsToString(array $htmlOptions, array $context = []) : string |
|
92 | - { |
|
93 | - if (empty($htmlOptions)) { |
|
94 | - return ''; |
|
95 | - } |
|
96 | - |
|
97 | - $out = []; |
|
98 | - |
|
99 | - foreach ($htmlOptions as $k => $v) { |
|
100 | - |
|
101 | - if ($v instanceof \Closure) { |
|
102 | - $v = call_user_func_array($v, $context); |
|
103 | - } |
|
104 | - |
|
105 | - $out[] = htmlentities($k) . '="' . htmlentities($v, ENT_COMPAT) . '"'; |
|
106 | - } |
|
107 | - |
|
108 | - return implode(' ', $out); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Allows to make column title by it key or attribute name |
|
113 | - * @param string|int $key |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - public static function columnTitle($key) : string |
|
117 | - { |
|
118 | - if (is_numeric($key)) { |
|
119 | - return 'Column'; |
|
120 | - } |
|
121 | - |
|
122 | - return ucwords( |
|
123 | - trim( |
|
124 | - preg_replace_callback( |
|
125 | - '/([A-Z]|_|\.)/', |
|
126 | - function($word) { |
|
127 | - $word = $word[0]; |
|
128 | - |
|
129 | - if ($word == '_' || $word == '.') { |
|
130 | - return ' '; |
|
131 | - } |
|
132 | - |
|
133 | - return ' ' . strtolower($word); |
|
134 | - }, |
|
135 | - $key |
|
136 | - ) |
|
137 | - ) |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Helper for internal purposes |
|
143 | - * @param $id |
|
144 | - * @param $component |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public static function gridIdFormatter($id, $component) |
|
148 | - { |
|
149 | - if ($id == 0) { |
|
150 | - return $component; |
|
151 | - } |
|
152 | - |
|
153 | - return 'grid[' . $id . '][' . $component . ']'; |
|
154 | - } |
|
25 | + /** |
|
26 | + * A list of grid aliases |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + private static $aliases = [ |
|
30 | + 'column' => [ |
|
31 | + 'attribute' => AttributeColumn::class, |
|
32 | + 'raw' => CallbackColumn::class, |
|
33 | + 'callback' => CallbackColumn::class, |
|
34 | + 'actions' => ActionsColumn::class, |
|
35 | + 'view' => ViewColumn::class, |
|
36 | + ], |
|
37 | + 'formatter' => [ |
|
38 | + 'email' => EmailFormatter::class, |
|
39 | + 'image' => ImageFormatter::class, |
|
40 | + 'text' => TextFormatter::class, |
|
41 | + 'url' => UrlFormatter::class, |
|
42 | + 'raw' => RawFormatter::class, |
|
43 | + ], |
|
44 | + 'filter' => [ |
|
45 | + 'text' => TextFilter::class, |
|
46 | + 'dropdown' => DropdownFilter::class, |
|
47 | + ], |
|
48 | + 'renderer' => [ |
|
49 | + 'default' => DefaultRenderer::class, |
|
50 | + ], |
|
51 | + 'action' => [ |
|
52 | + 'delete' => DeleteAction::class, |
|
53 | + 'update' => EditAction::class, |
|
54 | + 'edit' => EditAction::class, |
|
55 | + 'show' => ShowAction::class, |
|
56 | + 'view' => ShowAction::class, |
|
57 | + 'action' => Action::class, |
|
58 | + ] |
|
59 | + ]; |
|
60 | + |
|
61 | + private function __construct() {} |
|
62 | + |
|
63 | + /** |
|
64 | + * Useful in case you want to register a new alias for your project |
|
65 | + * @param string $context |
|
66 | + * @param string $alias |
|
67 | + * @param string $aliasTo |
|
68 | + */ |
|
69 | + public static function registerAlias(string $context, string $alias, string $aliasTo) |
|
70 | + { |
|
71 | + self::$aliases[$context][$alias] = $aliasTo; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Allows to resolve class name by its alias |
|
76 | + * @param string $context |
|
77 | + * @param string $alias |
|
78 | + * @return mixed |
|
79 | + */ |
|
80 | + public static function resolveAlias(string $context, string $alias) |
|
81 | + { |
|
82 | + return self::$aliases[$context][$alias] ?? $alias; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Allows to convert options array to html string |
|
87 | + * @param array $htmlOptions |
|
88 | + * @param array $context - context is variables, which are allowed to use when property value calculated dynamically |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public static function htmlOptionsToString(array $htmlOptions, array $context = []) : string |
|
92 | + { |
|
93 | + if (empty($htmlOptions)) { |
|
94 | + return ''; |
|
95 | + } |
|
96 | + |
|
97 | + $out = []; |
|
98 | + |
|
99 | + foreach ($htmlOptions as $k => $v) { |
|
100 | + |
|
101 | + if ($v instanceof \Closure) { |
|
102 | + $v = call_user_func_array($v, $context); |
|
103 | + } |
|
104 | + |
|
105 | + $out[] = htmlentities($k) . '="' . htmlentities($v, ENT_COMPAT) . '"'; |
|
106 | + } |
|
107 | + |
|
108 | + return implode(' ', $out); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Allows to make column title by it key or attribute name |
|
113 | + * @param string|int $key |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + public static function columnTitle($key) : string |
|
117 | + { |
|
118 | + if (is_numeric($key)) { |
|
119 | + return 'Column'; |
|
120 | + } |
|
121 | + |
|
122 | + return ucwords( |
|
123 | + trim( |
|
124 | + preg_replace_callback( |
|
125 | + '/([A-Z]|_|\.)/', |
|
126 | + function($word) { |
|
127 | + $word = $word[0]; |
|
128 | + |
|
129 | + if ($word == '_' || $word == '.') { |
|
130 | + return ' '; |
|
131 | + } |
|
132 | + |
|
133 | + return ' ' . strtolower($word); |
|
134 | + }, |
|
135 | + $key |
|
136 | + ) |
|
137 | + ) |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Helper for internal purposes |
|
143 | + * @param $id |
|
144 | + * @param $component |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public static function gridIdFormatter($id, $component) |
|
148 | + { |
|
149 | + if ($id == 0) { |
|
150 | + return $component; |
|
151 | + } |
|
152 | + |
|
153 | + return 'grid[' . $id . '][' . $component . ']'; |
|
154 | + } |
|
155 | 155 | } |
156 | 156 | \ No newline at end of file |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | class BooleanFormatter implements IFormatter |
6 | 6 | { |
7 | - public function format($value): string |
|
8 | - { |
|
9 | - return $value ? 'Yes' : 'No'; |
|
10 | - } |
|
7 | + public function format($value): string |
|
8 | + { |
|
9 | + return $value ? 'Yes' : 'No'; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -4,8 +4,8 @@ |
||
4 | 4 | |
5 | 5 | class RawFormatter implements IFormatter |
6 | 6 | { |
7 | - public function format($value): string |
|
8 | - { |
|
9 | - return $value; |
|
10 | - } |
|
7 | + public function format($value): string |
|
8 | + { |
|
9 | + return $value; |
|
10 | + } |
|
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -4,31 +4,31 @@ |
||
4 | 4 | |
5 | 5 | class CallbackColumn extends BaseColumn |
6 | 6 | { |
7 | - /** |
|
8 | - * @var string |
|
9 | - */ |
|
10 | - public $formatters = ['raw']; |
|
7 | + /** |
|
8 | + * @var string |
|
9 | + */ |
|
10 | + public $formatters = ['raw']; |
|
11 | 11 | |
12 | - /** |
|
13 | - * @var bool |
|
14 | - */ |
|
15 | - public $sortable = false; |
|
12 | + /** |
|
13 | + * @var bool |
|
14 | + */ |
|
15 | + public $sortable = false; |
|
16 | 16 | |
17 | - /** |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - protected function configTests(): array |
|
21 | - { |
|
22 | - return array_merge(parent::configTests(), [ |
|
23 | - 'value' => 'closure', |
|
24 | - ]); |
|
25 | - } |
|
17 | + /** |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + protected function configTests(): array |
|
21 | + { |
|
22 | + return array_merge(parent::configTests(), [ |
|
23 | + 'value' => 'closure', |
|
24 | + ]); |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * @inheritdoc |
|
29 | - */ |
|
30 | - public function _renderValue($row) |
|
31 | - { |
|
32 | - return call_user_func($this->value, $row); |
|
33 | - } |
|
27 | + /** |
|
28 | + * @inheritdoc |
|
29 | + */ |
|
30 | + public function _renderValue($row) |
|
31 | + { |
|
32 | + return call_user_func($this->value, $row); |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | \ No newline at end of file |