From 368c38fd9a2f0575c05059549ac8620aea3b890c Mon Sep 17 00:00:00 2001 From: Ivan Date: Tue, 24 Oct 2023 12:05:37 +0200 Subject: [PATCH] Release version 2.0.23 ISSUE: CS-4769 --- Setup/Patch/Data/AddResourcesToRole.php | 90 +++++++++++++++++++++++++ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 Setup/Patch/Data/AddResourcesToRole.php diff --git a/Setup/Patch/Data/AddResourcesToRole.php b/Setup/Patch/Data/AddResourcesToRole.php new file mode 100644 index 0000000..2547537 --- /dev/null +++ b/Setup/Patch/Data/AddResourcesToRole.php @@ -0,0 +1,90 @@ +moduleDataSetup = $moduleDataSetup; + $this->moduleList = $moduleList; + } + + /** + * Apply patch + * + * @return void + */ + public function apply() + { + $moduleVersion = $this->moduleList->getOne('SendCloud_SendCloud')['setup_version']; + + if (version_compare($moduleVersion, '2.0.23', '<=')) { + $connection = $this->moduleDataSetup->getConnection(); + $aclRoleTable = $this->moduleDataSetup->getTable('authorization_role'); + $aclRuleTable = $this->moduleDataSetup->getTable('authorization_rule'); + + $roleId = $connection->fetchOne( + $connection->select() + ->from($aclRoleTable, ['role_id']) + ->where('role_name = ?', self::ROLE_NAME) + ); + + if ($roleId) { + $resourcesToAdd = []; + + foreach (self::RESOURCES as $resource) { + $resourcesToAdd[] = [ + 'role_id' => $roleId, + 'resource_id' => $resource, + 'permission' => 'allow' + ]; + } + + $connection->insertOnDuplicate($aclRuleTable, $resourcesToAdd); + } + } + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } + + /** + * Get array of patches that have to be executed prior to this + * + * @return string[] + */ + public static function getDependencies() + { + return []; + } +} diff --git a/composer.json b/composer.json index 3bc693e..19de03a 100644 --- a/composer.json +++ b/composer.json @@ -4,7 +4,7 @@ "type": "magento2-module", "homepage": "https://www.sendcloud.com/", "license": "Apache-2.0", - "version": "2.0.22", + "version": "2.0.23", "require": { "php": "~7.1.0|~7.2.0|~7.3.0|~7.4.0|~8.1.0|~8.2.0" }, diff --git a/etc/module.xml b/etc/module.xml index 81dbdb8..ddbe0dd 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +