Completed
Pull Request — 8.x-1.x (#8)
by Vijay
02:51
created

media.module::media_form_alter()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 26
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 14
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 26
rs 8.8571
1
<?php
2
3
/**
4
 * @file
5
 * Contains media.module.
6
 */
7
8
use Drupal\Core\Routing\RouteMatchInterface;
9
use Drupal\Core\Form\FormStateInterface;
10
11
/**
12
 * Implements hook_help().
13
 */
14
function media_help($route_name, RouteMatchInterface $route_match) {
0 ignored issues
show
Unused Code introduced by
The parameter $route_match is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
15
  switch ($route_name) {
16
    // Main module help for the media module.
17
    case 'help.page.media':
18
      $output = '';
19
      $output .= '<h3>' . t('About') . '</h3>';
20
      $output .= '<p>' . t('Media module for Drupal 8') . '</p>';
21
      return $output;
22
23
    default:
24
  }
25
}
26
27
/**
28
 * Implements hook_form_alter().
29
 */
30
function media_form_alter(&$form, FormStateInterface &$form_state) {
0 ignored issues
show
Unused Code introduced by
The parameter $form_state is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
31
  if (isset($form['#form_id'])) {
32
    if ($form['#form_id'] == 'entity_browser_media_library_form') {
33
      // Attach our library.
34
      $form['#attached']['library'][] = 'media/view';
35
36
      // Style the submit button.
37
      $form['actions']['submit']['#value'] = t('Select Media Files');
38
      $form['actions']['submit']['#attributes']['class'][] = 'button--primary';
39
      $form['actions']['submit']['#attributes']['class'][] = 'entity-browser-modal-target';
40
41
      // Wrap actions so we can float them at the bottom of the browser.
42
      $form['actions_wrap'] = [
43
        '#type' => 'container',
44
        '#attributes' => [
45
          'class' => 'file-browser-actions',
46
        ],
47
        0 => $form['actions'],
48
      ];
49
      unset($form['actions']);
50
51
      // Add a class for generic styling.
52
      $form['#attributes']['class'][] = 'file-browser-form';
53
    }
54
  }
55
}
56