Commit ad32af4e authored by Jesse van de Water's avatar Jesse van de Water Committed by Fabian de Rijk
Browse files

#3272948: possible solution disappearing blocks

parent e62d9778
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
 * Onedrive module.
 */

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_theme().
 */
@@ -34,3 +36,37 @@ function o365_onedrive_o365_auth_scopes(array &$scopes) {
  $scopes[] = 'Files.Read.All';
  $scopes[] = 'Files.Read.Selected';
}

function o365_onedrive_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $config = \Drupal::config('o365.block_settings');

  if ($form_id == 'block_settings_form') {

    //    $form['value']['onedrive_block'] = [
    $form['block_onedrive'] = [
      '#type' => 'textarea',
      '#title' => t('OneDrive block text'),
      '#description' => t('Enter the text you would like to show'),
      '#default_value' => $config->get('block_onedrive'),
      '#states' => [
        'visible' => [
          ':input[name="show_block"]' => ['checked' => TRUE],
        ],
      ],
    ];
  }

}

/**
 * Implements hook_preprocess().
 */
function o365_onedrive_preprocess_page(&$variables) {

  if (\Drupal::config('o365.block_settings')->get('show_block') == TRUE) {
    $variables['block_onedrive'] = \Drupal::config('o365.block_settings')
      ->get('block_onedrive');
  }

}
+35 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
 * Implemented hooks for the o365_outlook_mail module.
 */

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_o365_auth_scopes().
 */
@@ -46,3 +48,36 @@ function o365_outlook_mail_theme($existing, $type, $theme, $path) {
    ],
  ];
}

function o365_outlook_mail_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $config = \Drupal::config('o365.block_settings');

  if ($form_id == 'block_settings_form') {

    //    $form['value']['onedrive_block'] = [
    $form['block_mail'] = [
      '#type' => 'textarea',
      '#title' => t('Mail block text'),
      '#description' => t('Enter the text you would like to show'),
      '#default_value' => $config->get('block_mail'),
      '#states' => [
        'visible' => [
          ':input[name="show_block"]' => ['checked' => TRUE],
        ],
      ],
    ];
  }

}

///**
// * Implements hook_preprocess().
// */
//function o365_outlook_mail_preprocess_page(&$variables) {
//
//  if (\Drupal::config('o365.block_settings')->get('show_block') == TRUE) {
//    $variables['block_mail'] = \Drupal::config('o365.block_settings')
//      ->get('block_mail');
//  }
//
//}
+5 −0
Original line number Diff line number Diff line
@@ -8,6 +8,11 @@ o365.api_settings_form:
  route_name: o365.api_settings_form
  description: 'API settings for the Office 365 Connector module'
  parent: o365.settings_form
o365.block_settings_form:
  title: 'Block Settings'
  route_name: o365.block_settings_form
  description: 'General block settings for the Office 365 Connector module'
  parent: o365.block_settings_form
o365.auth_scopes:
  title: 'Office 365 scopes'
  description: 'The needed authorization scopes for correct Office 365 integration'
+4 −0
Original line number Diff line number Diff line
@@ -6,3 +6,7 @@ o365.api_settings_form:
  title: 'API settings'
  route_name: o365.api_settings_form
  base_route: o365.settings_form
o365.block_settings_form:
  title: 'Block settings'
  route_name: o365.block_settings_form
  base_route: o365.settings_form
+10 −0
Original line number Diff line number Diff line
@@ -18,6 +18,16 @@ o365.api_settings_form:
  options:
    _admin_route: TRUE

o365.block_settings_form:
  path: '/admin/config/system/o365/settings/block'
  defaults:
    _form: '\Drupal\o365\Form\BlockSettingsForm'
    _title: 'Office 365 Block Settings'
  requirements:
    _permission: 'access o365 settings page'
  options:
    _admin_route: TRUE

o365.auth_scopes:
  path: '/admin/reports/o365-auth-scopes'
  defaults:
Loading