![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-catalog/Ui/Component/Product/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Catalog\Ui\Component\Product; use Magento\Framework\AuthorizationInterface; use Magento\Framework\View\Element\UiComponentInterface; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Ui\Component\AbstractComponent; /** * Class MassAction for Component Product */ class MassAction extends AbstractComponent { const NAME = 'massaction'; /** * @var AuthorizationInterface */ private $authorization; /** * Constructor * * @param AuthorizationInterface $authorization * @param ContextInterface $context * @param UiComponentInterface[] $components * @param array $data */ public function __construct( AuthorizationInterface $authorization, ContextInterface $context, array $components = [], array $data = [] ) { $this->authorization = $authorization; parent::__construct($context, $components, $data); } /** * @inheritdoc */ public function prepare() : void { $config = $this->getConfiguration(); foreach ($this->getChildComponents() as $actionComponent) { $actionType = $actionComponent->getConfiguration()['type']; if ($this->isActionAllowed($actionType)) { // phpcs:ignore Magento2.Performance.ForeachArrayMerge $config['actions'][] = array_merge($actionComponent->getConfiguration()); } } $origConfig = $this->getConfiguration(); if ($origConfig !== $config) { $config = array_replace_recursive($config, $origConfig); } $this->setData('config', $config); $this->components = []; parent::prepare(); } /** * @inheritdoc */ public function getComponentName() : string { return static::NAME; } /** * Check if the given type of action is allowed * * @param string $actionType * @return bool */ public function isActionAllowed($actionType) : bool { $isAllowed = true; switch ($actionType) { case 'delete': $isAllowed = $this->authorization->isAllowed('Magento_Catalog::products'); break; case 'status': $isAllowed = $this->authorization->isAllowed('Magento_Catalog::products'); break; case 'attributes': $isAllowed = $this->authorization->isAllowed('Magento_Catalog::update_attributes'); break; default: break; } return $isAllowed; } }