From 6c676e382441bb461824d8436235f054da59801c Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Thu, 24 Sep 2020 21:34:54 +0100 Subject: [PATCH 01/10] Init 2.x of Azure Storage. --- azure_storage.info.yml | 5 +- azure_storage.install | 12 +--- azure_storage.links.menu.yml | 2 +- azure_storage.permissions.yml | 2 + azure_storage.routing.yml | 5 +- azure_storage.services.yml | 7 +++ composer.json | 4 +- config/install/azure_storage.settings.yml | 5 +- src/AzureStorageClient.php | 77 +++++++++++++++++++++++ src/AzureStorageClientInterface.php | 38 +++++++++++ src/Form/SettingsForm.php | 10 ++- 11 files changed, 147 insertions(+), 20 deletions(-) create mode 100644 azure_storage.permissions.yml create mode 100644 azure_storage.services.yml create mode 100644 src/AzureStorageClientInterface.php diff --git a/azure_storage.info.yml b/azure_storage.info.yml index 73a0712..46db5c9 100644 --- a/azure_storage.info.yml +++ b/azure_storage.info.yml @@ -1,5 +1,6 @@ name: Azure Storage Integration type: module description: 'Integrates Azure Storage with Drupal' -core: 8.x -package: azure \ No newline at end of file +core_version_requirement: ^8.8.3 || ^9 +package: Azure +configure: azure_storage.settings_form diff --git a/azure_storage.install b/azure_storage.install index 311cf2e..9d89a8e 100644 --- a/azure_storage.install +++ b/azure_storage.install @@ -13,15 +13,7 @@ use Drupal\Core\Url; */ function azure_storage_requirements($phase) { $requirements = []; - if ($phase == 'install') { - if (!class_exists('\Aws\Azure Storage\Azure StorageClient')) { - $requirements['azure_storage_library'] = [ - 'description' => t('azure_storage require Azure Storage library.'), - 'severity' => REQUIREMENT_ERROR, - ]; - } - } - if ($phase == 'runtime') { + if ($phase === 'runtime') { $azure_storage_config = \Drupal::config('azure_storage.settings'); $access_key = $azure_storage_config->get('access_key'); $secret_key = $azure_storage_config->get('secret_key'); @@ -159,4 +151,4 @@ function azure_storage_install() { \Drupal::database()->query("ALTER TABLE {azure_storage_file} ADD PRIMARY KEY (uri)"); break; } -} \ No newline at end of file +} diff --git a/azure_storage.links.menu.yml b/azure_storage.links.menu.yml index e4247f6..8812fe1 100644 --- a/azure_storage.links.menu.yml +++ b/azure_storage.links.menu.yml @@ -2,4 +2,4 @@ azure_storage.settings_form: title: 'Azure Storage Settings' route_name: azure_storage.settings_form description: 'Configure Azure Storage Settings' - parent: system.admin_config_system + parent: system.admin_config_services diff --git a/azure_storage.permissions.yml b/azure_storage.permissions.yml new file mode 100644 index 0000000..6ba12c8 --- /dev/null +++ b/azure_storage.permissions.yml @@ -0,0 +1,2 @@ +administer azure storage: + title: 'Administer Azure Storage configuration' diff --git a/azure_storage.routing.yml b/azure_storage.routing.yml index 784ab25..48c03a0 100644 --- a/azure_storage.routing.yml +++ b/azure_storage.routing.yml @@ -1,10 +1,9 @@ azure_storage.settings_form: - path: '/admin/config/azure_storage/settings' + path: '/admin/config/services/azure-storage' defaults: _form: '\Drupal\azure_storage\Form\SettingsForm' _title: 'Azure Storage Settings Form' requirements: - _permission: 'access administration pages' + _permission: 'administer azure storage' options: _admin_route: TRUE - diff --git a/azure_storage.services.yml b/azure_storage.services.yml new file mode 100644 index 0000000..863c270 --- /dev/null +++ b/azure_storage.services.yml @@ -0,0 +1,7 @@ +services: + logger.channel.azure_storage: + parent: logger.channel_base + arguments: ['azure_storage'] + azure_storage.client: + class: '\Drupal\azure_storage\AzureStorageClient' + arguments: ['@config.factory', '@logger.channel.azure_storage'] diff --git a/composer.json b/composer.json index 12d2f53..f23165c 100644 --- a/composer.json +++ b/composer.json @@ -5,12 +5,12 @@ "keywords": ["Drupal"], "license": "GPL-2.0+", "homepage": "https://www.drupal.org/project/azure_storage", - "minimum-stability": "dev", "support": { "issues": "https://www.drupal.org/project/issues/azure_storage", "source": "http://cgit.drupalcode.org/azure_storage" }, "require": { - "microsoft/azure-storage": "*" + "microsoft/azure-storage-queue": "^1.3", + "microsoft/azure-storage-common": "^1.5" } } diff --git a/config/install/azure_storage.settings.yml b/config/install/azure_storage.settings.yml index 1c7ea79..2d52d74 100644 --- a/config/install/azure_storage.settings.yml +++ b/config/install/azure_storage.settings.yml @@ -1 +1,4 @@ -azure_storage: +protocol: 'https' +account_name: '' +account_key: '' +endpoint_suffix: '' diff --git a/src/AzureStorageClient.php b/src/AzureStorageClient.php index e69de29..884dab5 100644 --- a/src/AzureStorageClient.php +++ b/src/AzureStorageClient.php @@ -0,0 +1,77 @@ +config = $config_factory->get('azure_storage.settings'); + $this->logger = $logger; + } + + /** + * {@inheritDoc} + */ + public function setStorageQueue($connection_string = NULL) { + if ($connection_string === NULL) { + $protocol = $this->config->get('protocol'); + $account_name = $this->config->get('account_name'); + $account_key = $this->config->get('account_key'); + $endpoint_suffix = $this->config->get('endpoint_suffix'); + $connection_string = "DefaultEndpointsProtocol=$protocol;AccountName=$account_name;AccountKey=$account_key;EndpointSuffix=$endpoint_suffix"; + } + $this->queueClient = QueueRestProxy::createQueueService($connection_string); + return $this; + } + + /** + * {@inheritDoc} + */ + function addMessageToQueue($queue_name, $message) { + try { + $this->queueClient->createMessage($queue_name, $message); + } + catch (ServiceException $e) { + $this->logger->error($e->getMessage()); + } + return $this; + } + +} diff --git a/src/AzureStorageClientInterface.php b/src/AzureStorageClientInterface.php new file mode 100644 index 0000000..c1c0c64 --- /dev/null +++ b/src/AzureStorageClientInterface.php @@ -0,0 +1,38 @@ + TRUE, ]; + $form['endpoint_suffix'] = [ + '#type' => 'textfield', + '#title' => $this->t('Endpoint Suffix'), + '#description' => $this->t('The Endpoint Suffix for Azure Storage'), + '#default_value' => $config->get('endpoint_suffix'), + ]; + return parent::buildForm($form, $form_state); } @@ -73,6 +80,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { ->set('protocol', $form_state->getValue('protocol')) ->set('account_name', $form_state->getValue('account_name')) ->set('account_key', $form_state->getValue('account_key')) + ->set('endpoint_suffix', $form_state->getValue('endpoint_suffix')) ->save(); } From 258e1d4aee5fd343245829cfc5a94984cba99d73 Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Thu, 24 Sep 2020 23:02:12 +0100 Subject: [PATCH 02/10] Bool return value in AzureStorageClient::addMessageToQueue(). --- composer.json | 30 +++++++++++++++-------------- src/AzureStorageClient.php | 13 ++++++++----- src/AzureStorageClientInterface.php | 16 +++++++-------- 3 files changed, 32 insertions(+), 27 deletions(-) diff --git a/composer.json b/composer.json index f23165c..eafdbef 100644 --- a/composer.json +++ b/composer.json @@ -1,16 +1,18 @@ { - "name": "drupal/azure_storage", - "type": "drupal-module", - "description": "Azure Storage Integration", - "keywords": ["Drupal"], - "license": "GPL-2.0+", - "homepage": "https://www.drupal.org/project/azure_storage", - "support": { - "issues": "https://www.drupal.org/project/issues/azure_storage", - "source": "http://cgit.drupalcode.org/azure_storage" - }, - "require": { - "microsoft/azure-storage-queue": "^1.3", - "microsoft/azure-storage-common": "^1.5" - } + "name": "drupal/azure_storage", + "type": "drupal-module", + "description": "Azure Storage Integration", + "keywords": [ + "Drupal" + ], + "license": "GPL-2.0+", + "homepage": "https://www.drupal.org/project/azure_storage", + "support": { + "issues": "https://www.drupal.org/project/issues/azure_storage", + "source": "http://cgit.drupalcode.org/azure_storage" + }, + "require": { + "microsoft/azure-storage-queue": "^1.3", + "microsoft/azure-storage-common": "^1.5" + } } diff --git a/src/AzureStorageClient.php b/src/AzureStorageClient.php index 884dab5..300ad60 100644 --- a/src/AzureStorageClient.php +++ b/src/AzureStorageClient.php @@ -15,7 +15,7 @@ class AzureStorageClient implements AzureStorageClientInterface { /** - * The Azure Storage settings + * The Azure Storage settings. * * @var \Drupal\Core\Config\Config */ @@ -29,6 +29,8 @@ class AzureStorageClient implements AzureStorageClientInterface { protected $logger; /** + * Azure Queue client. + * * @var \MicrosoftAzure\Storage\Queue\Internal\IQueue */ protected $queueClient; @@ -47,7 +49,7 @@ public function __construct(ConfigFactoryInterface $config_factory, LoggerInterf } /** - * {@inheritDoc} + * {@inheritdoc} */ public function setStorageQueue($connection_string = NULL) { if ($connection_string === NULL) { @@ -62,16 +64,17 @@ public function setStorageQueue($connection_string = NULL) { } /** - * {@inheritDoc} + * {@inheritdoc} */ - function addMessageToQueue($queue_name, $message) { + public function addMessageToQueue($queue_name, $message) { try { $this->queueClient->createMessage($queue_name, $message); } catch (ServiceException $e) { $this->logger->error($e->getMessage()); + return FALSE; } - return $this; + return TRUE; } } diff --git a/src/AzureStorageClientInterface.php b/src/AzureStorageClientInterface.php index c1c0c64..d7aa7d5 100644 --- a/src/AzureStorageClientInterface.php +++ b/src/AzureStorageClientInterface.php @@ -14,25 +14,25 @@ interface AzureStorageClientInterface { * * When no connection string is given, one will be looked up from config. * - * @param $connection_string - * Optional Azure connection string. + * @param string $connection_string + * Optional Azure connection string. * * @return $this - * AzureClient. + * AzureClient. */ public function setStorageQueue($connection_string = NULL); /** * Adds a message to the queue. * - * @param $queue_name + * @param string $queue_name * Azure Storage Queue name. - * @param $message + * @param string $message * Message. * - * @return $this - * AzureClient. + * @return bool + * TRUE or FALSE on failure. */ - function addMessageToQueue($queue_name, $message); + public function addMessageToQueue($queue_name, $message); } From 18dc962138c2c4903ef150009df94a3de46185c3 Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Fri, 25 Sep 2020 09:47:44 +0100 Subject: [PATCH 03/10] Added key module dependency for account key storage. --- azure_storage.info.yml | 2 ++ src/AzureStorage.php | 36 ++++++++++++++++++++++++++++++++++++ src/AzureStorageClient.php | 2 +- src/Form/SettingsForm.php | 2 +- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/AzureStorage.php diff --git a/azure_storage.info.yml b/azure_storage.info.yml index 46db5c9..3108965 100644 --- a/azure_storage.info.yml +++ b/azure_storage.info.yml @@ -4,3 +4,5 @@ description: 'Integrates Azure Storage with Drupal' core_version_requirement: ^8.8.3 || ^9 package: Azure configure: azure_storage.settings_form +dependencies: + - key:key diff --git a/src/AzureStorage.php b/src/AzureStorage.php new file mode 100644 index 0000000..13359ee --- /dev/null +++ b/src/AzureStorage.php @@ -0,0 +1,36 @@ +get('account_key'); + } + if ($key_id) { + /** @var \Drupal\key\KeyRepositoryInterface $key_repository */ + $key_repository = \Drupal::service('key.repository'); + $key_entity = $key_repository->getKey($key_id); + if ($key_entity) { + return $key_entity->getKeyValue(); + } + } + return NULL; + } + +} diff --git a/src/AzureStorageClient.php b/src/AzureStorageClient.php index 300ad60..86c4feb 100644 --- a/src/AzureStorageClient.php +++ b/src/AzureStorageClient.php @@ -55,7 +55,7 @@ public function setStorageQueue($connection_string = NULL) { if ($connection_string === NULL) { $protocol = $this->config->get('protocol'); $account_name = $this->config->get('account_name'); - $account_key = $this->config->get('account_key'); + $account_key = AzureStorage::getAccountKey(); $endpoint_suffix = $this->config->get('endpoint_suffix'); $connection_string = "DefaultEndpointsProtocol=$protocol;AccountName=$account_name;AccountKey=$account_key;EndpointSuffix=$endpoint_suffix"; } diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index c833bf2..70b93b2 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -53,7 +53,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { ]; $form['account_key'] = [ - '#type' => 'textfield', + '#type' => 'key_select', '#title' => $this->t('Account Key'), '#description' => $this->t('The Account Key for Azure Storage'), '#default_value' => $config->get('account_key'), From 2a43f751d33487696654971b14a150d21e450d06 Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Mon, 28 Sep 2020 11:23:18 +0100 Subject: [PATCH 04/10] Added AzureStorageClient::getStorageQueueConnectionString(). --- src/AzureStorageClient.php | 19 +++++++++++++------ src/AzureStorageClientInterface.php | 13 ++++++++++++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/AzureStorageClient.php b/src/AzureStorageClient.php index 86c4feb..deb9e39 100644 --- a/src/AzureStorageClient.php +++ b/src/AzureStorageClient.php @@ -53,11 +53,7 @@ public function __construct(ConfigFactoryInterface $config_factory, LoggerInterf */ public function setStorageQueue($connection_string = NULL) { if ($connection_string === NULL) { - $protocol = $this->config->get('protocol'); - $account_name = $this->config->get('account_name'); - $account_key = AzureStorage::getAccountKey(); - $endpoint_suffix = $this->config->get('endpoint_suffix'); - $connection_string = "DefaultEndpointsProtocol=$protocol;AccountName=$account_name;AccountKey=$account_key;EndpointSuffix=$endpoint_suffix"; + $connection_string = $this->getStorageQueueConnectionString(); } $this->queueClient = QueueRestProxy::createQueueService($connection_string); return $this; @@ -66,7 +62,18 @@ public function setStorageQueue($connection_string = NULL) { /** * {@inheritdoc} */ - public function addMessageToQueue($queue_name, $message) { + public function getStorageQueueConnectionString(array $params = []) : string { + $protocol = $params['protocol'] ?? $this->config->get('protocol'); + $account_name = $params['account_name'] ?? $this->config->get('account_name'); + $account_key = $params['account_key'] ?? AzureStorage::getAccountKey(); + $endpoint_suffix = $params['endpoint_suffix'] ?? $this->config->get('endpoint_suffix'); + return "DefaultEndpointsProtocol=$protocol;AccountName=$account_name;AccountKey=$account_key;EndpointSuffix=$endpoint_suffix"; + } + + /** + * {@inheritdoc} + */ + public function addMessageToQueue($queue_name, $message) : bool { try { $this->queueClient->createMessage($queue_name, $message); } diff --git a/src/AzureStorageClientInterface.php b/src/AzureStorageClientInterface.php index d7aa7d5..5f674a8 100644 --- a/src/AzureStorageClientInterface.php +++ b/src/AzureStorageClientInterface.php @@ -22,6 +22,17 @@ interface AzureStorageClientInterface { */ public function setStorageQueue($connection_string = NULL); + /** + * Get a storage queue connection string. + * + * @param array $params + * Optional parameters with fallback. + * + * @return string + * Connection string. + */ + public function getStorageQueueConnectionString(array $params = []) : string; + /** * Adds a message to the queue. * @@ -33,6 +44,6 @@ public function setStorageQueue($connection_string = NULL); * @return bool * TRUE or FALSE on failure. */ - public function addMessageToQueue($queue_name, $message); + public function addMessageToQueue($queue_name, $message) : bool; } From 1bcc8ddc96889a303ab1fbeceb1b0d8fb38f0a4e Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Wed, 21 Oct 2020 16:52:12 +0100 Subject: [PATCH 05/10] Simplified storageQueueService retrieval. --- src/AzureStorageClient.php | 24 ++++++++---------------- src/AzureStorageClientInterface.php | 25 ++++++++++--------------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/AzureStorageClient.php b/src/AzureStorageClient.php index deb9e39..e688028 100644 --- a/src/AzureStorageClient.php +++ b/src/AzureStorageClient.php @@ -3,7 +3,6 @@ namespace Drupal\azure_storage; use Drupal\Core\Config\ConfigFactoryInterface; -use MicrosoftAzure\Storage\Common\Exceptions\ServiceException; use MicrosoftAzure\Storage\Queue\QueueRestProxy; use Psr\Log\LoggerInterface; @@ -51,7 +50,7 @@ public function __construct(ConfigFactoryInterface $config_factory, LoggerInterf /** * {@inheritdoc} */ - public function setStorageQueue($connection_string = NULL) { + public function setStorageQueueService($connection_string = NULL) { if ($connection_string === NULL) { $connection_string = $this->getStorageQueueConnectionString(); } @@ -59,6 +58,13 @@ public function setStorageQueue($connection_string = NULL) { return $this; } + /** + * {@inheritdoc} + */ + public function getStorageQueueService() { + return $this->queueClient; + } + /** * {@inheritdoc} */ @@ -70,18 +76,4 @@ public function getStorageQueueConnectionString(array $params = []) : string { return "DefaultEndpointsProtocol=$protocol;AccountName=$account_name;AccountKey=$account_key;EndpointSuffix=$endpoint_suffix"; } - /** - * {@inheritdoc} - */ - public function addMessageToQueue($queue_name, $message) : bool { - try { - $this->queueClient->createMessage($queue_name, $message); - } - catch (ServiceException $e) { - $this->logger->error($e->getMessage()); - return FALSE; - } - return TRUE; - } - } diff --git a/src/AzureStorageClientInterface.php b/src/AzureStorageClientInterface.php index 5f674a8..8b48106 100644 --- a/src/AzureStorageClientInterface.php +++ b/src/AzureStorageClientInterface.php @@ -10,7 +10,7 @@ interface AzureStorageClientInterface { /** - * Set a storage queue. + * Set a storage queue service. * * When no connection string is given, one will be looked up from config. * @@ -20,7 +20,15 @@ interface AzureStorageClientInterface { * @return $this * AzureClient. */ - public function setStorageQueue($connection_string = NULL); + public function setStorageQueueService($connection_string = NULL); + + /** + * Get the storage queue service. + * + * @return \MicrosoftAzure\Storage\Queue\Internal\IQueue + * Azure Queue Service. + */ + public function getStorageQueueService(); /** * Get a storage queue connection string. @@ -33,17 +41,4 @@ public function setStorageQueue($connection_string = NULL); */ public function getStorageQueueConnectionString(array $params = []) : string; - /** - * Adds a message to the queue. - * - * @param string $queue_name - * Azure Storage Queue name. - * @param string $message - * Message. - * - * @return bool - * TRUE or FALSE on failure. - */ - public function addMessageToQueue($queue_name, $message) : bool; - } From 7201cb1518a6e7dfc1d2408486f4b161346b0cee Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Wed, 21 Oct 2020 17:25:20 +0100 Subject: [PATCH 06/10] Provide fallback to default storage queue service in getStorageQueueService(). --- src/AzureStorageClient.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/AzureStorageClient.php b/src/AzureStorageClient.php index e688028..fe57f06 100644 --- a/src/AzureStorageClient.php +++ b/src/AzureStorageClient.php @@ -62,6 +62,9 @@ public function setStorageQueueService($connection_string = NULL) { * {@inheritdoc} */ public function getStorageQueueService() { + if ($this->queueClient === NULL) { + $this->setStorageQueueService(); + } return $this->queueClient; } From 51c94e6f3fcd81b8370359509b788d583c4f4efe Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Wed, 21 Oct 2020 21:50:12 +0100 Subject: [PATCH 07/10] Added Test / Live Account Key variations. --- azure_storage.links.menu.yml | 2 +- azure_storage.routing.yml | 2 +- config/install/azure_storage.settings.yml | 4 +++- src/AzureStorage.php | 5 +++- src/Form/SettingsForm.php | 28 +++++++++++++++++++---- 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/azure_storage.links.menu.yml b/azure_storage.links.menu.yml index 8812fe1..e4acda0 100644 --- a/azure_storage.links.menu.yml +++ b/azure_storage.links.menu.yml @@ -1,5 +1,5 @@ azure_storage.settings_form: - title: 'Azure Storage Settings' + title: 'Azure Storage' route_name: azure_storage.settings_form description: 'Configure Azure Storage Settings' parent: system.admin_config_services diff --git a/azure_storage.routing.yml b/azure_storage.routing.yml index 48c03a0..6da2961 100644 --- a/azure_storage.routing.yml +++ b/azure_storage.routing.yml @@ -2,7 +2,7 @@ azure_storage.settings_form: path: '/admin/config/services/azure-storage' defaults: _form: '\Drupal\azure_storage\Form\SettingsForm' - _title: 'Azure Storage Settings Form' + _title: 'Azure Storage Settings' requirements: _permission: 'administer azure storage' options: diff --git a/config/install/azure_storage.settings.yml b/config/install/azure_storage.settings.yml index 2d52d74..8f4b34c 100644 --- a/config/install/azure_storage.settings.yml +++ b/config/install/azure_storage.settings.yml @@ -1,4 +1,6 @@ protocol: 'https' account_name: '' -account_key: '' +test_account_key: '' +live_account_key: '' +mode: 'test' endpoint_suffix: '' diff --git a/src/AzureStorage.php b/src/AzureStorage.php index 13359ee..96458ee 100644 --- a/src/AzureStorage.php +++ b/src/AzureStorage.php @@ -19,8 +19,11 @@ final class AzureStorage { * The key value if found or NULL. */ public static function getAccountKey($key_id = NULL) { + $settings = \Drupal::config('azure_storage.settings'); if ($key_id === NULL) { - $key_id = \Drupal::config('azure_storage.settings')->get('account_key'); + $mode = $settings->get('mode') ?? 'test'; + $config_key = $mode . '_account_key'; + $key_id = $settings->get($config_key); } if ($key_id) { /** @var \Drupal\key\KeyRepositoryInterface $key_repository */ diff --git a/src/Form/SettingsForm.php b/src/Form/SettingsForm.php index 70b93b2..b46d488 100644 --- a/src/Form/SettingsForm.php +++ b/src/Form/SettingsForm.php @@ -52,14 +52,32 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#required' => TRUE, ]; - $form['account_key'] = [ + $form['test_account_key'] = [ '#type' => 'key_select', - '#title' => $this->t('Account Key'), + '#title' => $this->t('Account Key (test)'), '#description' => $this->t('The Account Key for Azure Storage'), - '#default_value' => $config->get('account_key'), + '#default_value' => $config->get('test_account_key'), '#required' => TRUE, ]; + $form['live_account_key'] = [ + '#type' => 'key_select', + '#title' => $this->t('Account Key (live)'), + '#description' => $this->t('The Account Key for Azure Storage'), + '#default_value' => $config->get('live_account_key'), + '#required' => TRUE, + ]; + + $form['mode'] = [ + '#type' => 'radios', + '#title' => $this->t('Mode'), + '#options' => [ + 'test' => $this->t('Test'), + 'live' => $this->t('Live'), + ], + '#default_value' => $config->get('mode'), + ]; + $form['endpoint_suffix'] = [ '#type' => 'textfield', '#title' => $this->t('Endpoint Suffix'), @@ -79,7 +97,9 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->config('azure_storage.settings') ->set('protocol', $form_state->getValue('protocol')) ->set('account_name', $form_state->getValue('account_name')) - ->set('account_key', $form_state->getValue('account_key')) + ->set('test_account_key', $form_state->getValue('test_account_key')) + ->set('live_account_key', $form_state->getValue('live_account_key')) + ->set('mode', $form_state->getValue('mode')) ->set('endpoint_suffix', $form_state->getValue('endpoint_suffix')) ->save(); } From 8dc97ea41e9325d9beaede6a9a403efc79246772 Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Sat, 24 Oct 2020 13:53:09 +0100 Subject: [PATCH 08/10] Updated README.md. --- README.md | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c451b81..0cde730 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,45 @@ -# azure_storage +CONTENTS OF THIS FILE +--------------------- + + * Introduction + * Requirements + * Maintainers + + +INTRODUCTION +------------ + This project provides an easy integration with Microsoft Azure Storage services (blobs, tables and queues).. + + * For a full description of the module, visit the project page: + https://www.drupal.org/project/azure_storage + * To submit bug reports and feature suggestions or to track changes, use + the issue tracker on Drupal.org: + https://www.drupal.org/project/issues/azure_storage + + +REQUIREMENTS +------------ + +This module requires the following outside of Drupal core: + + * Key - https://www.drupal.org/project/key + + +INSTALLATION +------------ + + * Install the module as you would normally install a contributed + Drupal module. Visit [Installing Drupal 8 Modules](https://www.drupal.org/node/1897420) for further + information. + + +MAINTAINERS +----------- + + * Janak Singh (dakku) - https://www.drupal.org/u/dakku + * Sang Lostrie (baikho) - https://www.drupal.org/u/baikho + +### Supporting organizations: + + * [Access](https://www.drupal.org/access) - Development and maintenance From b7977a7f3896b7f509420deb85fc51be60e19fde Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Sun, 8 Nov 2020 12:17:39 +0000 Subject: [PATCH 09/10] Added local task tab links YAML file. --- azure_storage.links.task.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 azure_storage.links.task.yml diff --git a/azure_storage.links.task.yml b/azure_storage.links.task.yml new file mode 100644 index 0000000..2d22301 --- /dev/null +++ b/azure_storage.links.task.yml @@ -0,0 +1,4 @@ +azure_storage.settings_form: + title: 'Settings' + route_name: azure_storage.settings_form + base_route: azure_storage.settings_form From 740d37c9698003e9e579f84056caa5837fc52f47 Mon Sep 17 00:00:00 2001 From: Sang Lostrie Date: Mon, 9 Nov 2020 11:24:47 +0000 Subject: [PATCH 10/10] Discarded outdated runtime file system check and broken route reference. --- azure_storage.install | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/azure_storage.install b/azure_storage.install index 9d89a8e..25e35a7 100644 --- a/azure_storage.install +++ b/azure_storage.install @@ -14,18 +14,6 @@ use Drupal\Core\Url; function azure_storage_requirements($phase) { $requirements = []; if ($phase === 'runtime') { - $azure_storage_config = \Drupal::config('azure_storage.settings'); - $access_key = $azure_storage_config->get('access_key'); - $secret_key = $azure_storage_config->get('secret_key'); - if (!($access_key && $secret_key)) { - $requirements['azure_storage'] = [ - 'title' => t('Azure Storage File System'), - 'severity' => REQUIREMENT_ERROR, - 'description' => t('Azure Storage File System access key or secret key is not set and it is required for some functionalities to work. Please set it up at the Azure Storage File System module settings page.', [ - ':settings' => Url::fromRoute('azure_storage.admin_settings')->toString(), - ]), - ]; - } if (ini_get('allow_url_fopen')) { $requirements['azure_storage_allow_url_fopen'] = [