3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
8
namespace Magento \Backend \Block \Widget \Grid \Massaction ;
8
9
10
+ use Magento \Backend \Block \Template \Context ;
11
+ use Magento \Backend \Block \Widget ;
12
+ use Magento \Backend \Block \Widget \Grid \Column ;
13
+ use Magento \Backend \Block \Widget \Grid \ColumnSet ;
9
14
use Magento \Backend \Block \Widget \Grid \Massaction \VisibilityCheckerInterface as VisibilityChecker ;
10
15
use Magento \Framework \Data \Collection \AbstractDb ;
11
16
use Magento \Framework \DataObject ;
17
+ use Magento \Framework \DB \Select ;
18
+ use Magento \Framework \Json \EncoderInterface ;
19
+ use Magento \Quote \Model \Quote ;
20
+ use function count ;
21
+ use function is_array ;
12
22
13
23
/**
14
24
* Grid widget massaction block
15
25
*
16
26
* @api
17
- * @method \Magento\Quote\Model\ Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors
27
+ * @method Quote setHideFormElement(boolean $value) Hide Form element to prevent IE errors
18
28
* @method boolean getHideFormElement()
19
29
* @deprecated 100.2.0 in favour of UI component implementation
20
30
* @since 100.0.2
21
31
*/
22
- abstract class AbstractMassaction extends \ Magento \ Backend \ Block \ Widget
32
+ abstract class AbstractMassaction extends Widget
23
33
{
24
34
/**
25
- * @var \Magento\Framework\Json\ EncoderInterface
35
+ * @var EncoderInterface
26
36
*/
27
37
protected $ _jsonEncoder ;
28
38
@@ -39,13 +49,13 @@ abstract class AbstractMassaction extends \Magento\Backend\Block\Widget
39
49
protected $ _template = 'Magento_Backend::widget/grid/massaction.phtml ' ;
40
50
41
51
/**
42
- * @param \Magento\Backend\Block\Template\ Context $context
43
- * @param \Magento\Framework\Json\ EncoderInterface $jsonEncoder
52
+ * @param Context $context
53
+ * @param EncoderInterface $jsonEncoder
44
54
* @param array $data
45
55
*/
46
56
public function __construct (
47
- \ Magento \ Backend \ Block \ Template \ Context $ context ,
48
- \ Magento \ Framework \ Json \ EncoderInterface $ jsonEncoder ,
57
+ Context $ context ,
58
+ EncoderInterface $ jsonEncoder ,
49
59
array $ data = []
50
60
) {
51
61
$ this ->_jsonEncoder = $ jsonEncoder ;
@@ -118,15 +128,11 @@ private function isVisible(DataObject $item)
118
128
* Retrieve massaction item with id $itemId
119
129
*
120
130
* @param string $itemId
121
- * @return \Magento\Backend\Block\Widget\Grid\Massaction\ Item|null
131
+ * @return Item|null
122
132
*/
123
133
public function getItem ($ itemId )
124
134
{
125
- if (isset ($ this ->_items [$ itemId ])) {
126
- return $ this ->_items [$ itemId ];
127
- }
128
-
129
- return null ;
135
+ return $ this ->_items [$ itemId ] ?? null ;
130
136
}
131
137
132
138
/**
@@ -161,7 +167,7 @@ public function getItemsJson()
161
167
*/
162
168
public function getCount ()
163
169
{
164
- return sizeof ($ this ->_items );
170
+ return count ($ this ->_items );
165
171
}
166
172
167
173
/**
@@ -288,11 +294,11 @@ public function getGridIdsJson()
288
294
289
295
if ($ collection instanceof AbstractDb) {
290
296
$ idsSelect = clone $ collection ->getSelect ();
291
- $ idsSelect ->reset (\ Magento \ Framework \ DB \ Select::ORDER );
292
- $ idsSelect ->reset (\ Magento \ Framework \ DB \ Select::LIMIT_COUNT );
293
- $ idsSelect ->reset (\ Magento \ Framework \ DB \ Select::LIMIT_OFFSET );
294
- $ idsSelect ->reset (\ Magento \ Framework \ DB \ Select::COLUMNS );
295
- $ idsSelect ->columns ($ this ->getMassactionIdField (), ' main_table ' );
297
+ $ idsSelect ->reset (Select::ORDER );
298
+ $ idsSelect ->reset (Select::LIMIT_COUNT );
299
+ $ idsSelect ->reset (Select::LIMIT_OFFSET );
300
+ $ idsSelect ->reset (Select::COLUMNS );
301
+ $ idsSelect ->columns ($ this ->getMassactionIdField ());
296
302
$ idList = $ collection ->getConnection ()->fetchCol ($ idsSelect );
297
303
} else {
298
304
$ idList = $ collection ->setPageSize (0 )->getColumnValues ($ this ->getMassactionIdField ());
@@ -358,7 +364,7 @@ public function prepareMassactionColumn()
358
364
{
359
365
$ columnId = 'massaction ' ;
360
366
$ massactionColumn = $ this ->getLayout ()->createBlock (
361
- \ Magento \ Backend \ Block \ Widget \ Grid \ Column::class
367
+ Column::class
362
368
)->setData (
363
369
[
364
370
'index ' => $ this ->getMassactionIdField (),
@@ -378,7 +384,7 @@ public function prepareMassactionColumn()
378
384
$ gridBlock = $ this ->getParentBlock ();
379
385
$ massactionColumn ->setSelected ($ this ->getSelected ())->setGrid ($ gridBlock )->setId ($ columnId );
380
386
381
- /** @var $columnSetBlock \Magento\Backend\Block\Widget\Grid\ ColumnSet */
387
+ /** @var $columnSetBlock ColumnSet */
382
388
$ columnSetBlock = $ gridBlock ->getColumnSet ();
383
389
$ childNames = $ columnSetBlock ->getChildNames ();
384
390
$ siblingElement = count ($ childNames ) ? current ($ childNames ) : 0 ;
0 commit comments