* @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ declare(strict_types=1); namespace PrestaShop\PrestaShop\Adapter\Profile\Permission\CommandHandler; use Access; use PrestaShop\PrestaShop\Core\Domain\Profile\Permission\Command\UpdateModulePermissionsCommand; use PrestaShop\PrestaShop\Core\Domain\Profile\Permission\CommandHandler\UpdateModulePermissionsHandlerInterface; use PrestaShop\PrestaShop\Core\Domain\Profile\Permission\Exception\PermissionUpdateException; /** * Updates permissions for modules using legacy object model * * @internal */ final class UpdateModulePermissionsHandler implements UpdateModulePermissionsHandlerInterface { /** * @param UpdateModulePermissionsCommand $command * * @throws PermissionUpdateException */ public function handle(UpdateModulePermissionsCommand $command): void { $result = (new Access())->updateLgcModuleAccess( $command->getProfileId()->getValue(), $command->getModuleId()->getValue(), $command->getPermission()->getValue(), $command->isActive() ); if ('error' === $result) { throw new PermissionUpdateException('Failed to update module permissions'); } } }