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