Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
MassAction Class Reference
Inheritance diagram for MassAction:
AbstractComponent DataObject UiComponentInterface BlockInterface

Public Member Functions

 __construct (AuthorizationInterface $authorization, ContextInterface $context, array $components=[], array $data=[])
 
 prepare ()
 
 getComponentName ()
 
 isActionAllowed ($actionType)
 
- Public Member Functions inherited from AbstractComponent
 __construct (ContextInterface $context, array $components=[], array $data=[])
 
 getContext ()
 
 getName ()
 
 prepare ()
 
 toHtml ()
 
 render ()
 
 addComponent ($name, UiComponentInterface $component)
 
 getComponent ($name)
 
 getChildComponents ()
 
 renderChildComponent ($name)
 
 getTemplate ()
 
 getConfiguration ()
 
 getJsConfig (UiComponentInterface $component)
 
 setData ($key, $value=null)
 
 getData ($key='', $index=null)
 
 prepareDataSource (array $dataSource)
 
 getDataSourceData ()
 
- Public Member Functions inherited from DataObject
 __construct (array $data=[])
 
 addData (array $arr)
 
 setData ($key, $value=null)
 
 unsetData ($key=null)
 
 getData ($key='', $index=null)
 
 getDataByPath ($path)
 
 getDataByKey ($key)
 
 setDataUsingMethod ($key, $args=[])
 
 getDataUsingMethod ($key, $args=null)
 
 hasData ($key='')
 
 toArray (array $keys=[])
 
 convertToArray (array $keys=[])
 
 toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true)
 
 toJson (array $keys=[])
 
 convertToJson (array $keys=[])
 
 toString ($format='')
 
 __call ($method, $args)
 
 isEmpty ()
 
 serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"')
 
 debug ($data=null, &$objects=[])
 
 offsetSet ($offset, $value)
 
 offsetExists ($offset)
 
 offsetUnset ($offset)
 
 offsetGet ($offset)
 

Data Fields

const NAME = 'massaction'
 

Additional Inherited Members

- Protected Member Functions inherited from AbstractComponent
 prepareChildComponent (UiComponentInterface $component)
 
 initObservers (array & $data=[])
 
- Protected Member Functions inherited from DataObject
 _getData ($key)
 
 _underscore ($name)
 
- Protected Attributes inherited from AbstractComponent
 $context
 
 $components
 
 $componentData = []
 
 $dataSources = []
 
- Protected Attributes inherited from DataObject
 $_data = []
 
- Static Protected Attributes inherited from DataObject
static $_underscoreCache = []
 

Detailed Description

Definition at line 15 of file MassAction.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( AuthorizationInterface  $authorization,
ContextInterface  $context,
array  $components = [],
array  $data = [] 
)

Constructor

Parameters
AuthorizationInterface$authorization
ContextInterface$context
UiComponentInterface[]$components
array$data

Definition at line 32 of file MassAction.php.

37  {
38  $this->authorization = $authorization;
39  parent::__construct($context, $components, $data);
40  }

Member Function Documentation

◆ getComponentName()

getComponentName ( )

{Get component name

Returns
string
}

Implements UiComponentInterface.

Definition at line 69 of file MassAction.php.

69  : string
70  {
71  return static::NAME;
72  }

◆ isActionAllowed()

isActionAllowed (   $actionType)

Check if the given type of action is allowed

Parameters
string$actionType
Returns
bool

Definition at line 80 of file MassAction.php.

80  : bool
81  {
82  $isAllowed = true;
83  switch ($actionType) {
84  case 'delete':
85  $isAllowed = $this->authorization->isAllowed('Magento_Catalog::products');
86  break;
87  case 'status':
88  $isAllowed = $this->authorization->isAllowed('Magento_Catalog::products');
89  break;
90  case 'attributes':
91  $isAllowed = $this->authorization->isAllowed('Magento_Catalog::update_attributes');
92  break;
93  default:
94  break;
95  }
96  return $isAllowed;
97  }
$isAllowed
Definition: get.php:20

◆ prepare()

prepare ( )

{Prepare component configuration

Returns
void
}

Implements UiComponentInterface.

Definition at line 45 of file MassAction.php.

45  : void
46  {
47  $config = $this->getConfiguration();
48 
49  foreach ($this->getChildComponents() as $actionComponent) {
50  $actionType = $actionComponent->getConfiguration()['type'];
51  if ($this->isActionAllowed($actionType)) {
52  $config['actions'][] = $actionComponent->getConfiguration();
53  }
54  }
55  $origConfig = $this->getConfiguration();
56  if ($origConfig !== $config) {
57  $config = array_replace_recursive($config, $origConfig);
58  }
59 
60  $this->setData('config', $config);
61  $this->components = [];
62 
63  parent::prepare();
64  }
$config
Definition: fraud_order.php:17

Field Documentation

◆ NAME

const NAME = 'massaction'

Definition at line 17 of file MassAction.php.


The documentation for this class was generated from the following file: