bynder-4.0.0-beta1/modules/bynder_sns/bynder_sns.module

modules/bynder_sns/bynder_sns.module
<?php

/**
 * @file
 * Module hooks for the Bynder SNS module.
 */

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;

/**
 * Implements hook_form_FORM_ID_alter().
 */
function bynder_sns_form_bynder_configuration_form_alter(&$form, FormStateInterface $form_state) {

  $form['bynder_sns'] = [
    '#type' => 'details',
    '#title' => t('Amazon SNS notifications'),
    '#description' => t('Integration with the Amazon SNS module allows to process changes to assets in Bynder immediately. To set this up, a subscription must be configured for this Drupal installation, pointing to @subscription_url. Once set up the topic name should be logged as part of the successful confirmation. See the <a href=":documentation_url">documentation</a> for more information. Once configured, the background metadata refresh can be disabled.', [
      '@subscription_url' => Url::fromRoute('amazon_sns.notify')->setAbsolute()->toString(),
      '@documntation_url' => 'https://help.bynder.com/system/SNS_notifications.htm',
    ]),
    '#open' => TRUE,
  ];

  $config = \Drupal::configFactory()->getEditable('bynder_sns.settings');

  $form['bynder_sns']['topic'] = [
    '#type' => 'textfield',
    '#title' => t('Topic'),
    '#description' => t('Configure the SNS topic name, only notifications from this topic will be processed.'),
    '#placeholder' => 'arn:aws:sns:eu-central-1:......',
    '#default_value' => $config->get('topic'),
    '#size' => '100'
  ];

  $form['#submit'][] = 'bynder_sns_settings_submit';
}

/**
 * Form submit callback.
 */
function bynder_sns_settings_submit($form, FormStateInterface $form_state) {
  $config = \Drupal::configFactory()->getEditable('bynder_sns.settings');
  $config->set('topic', trim($form_state->getValue('topic')));
  $config->save();
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc