opcache.admin.inc::opcache_admin_form()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 14
nc 2
nop 2
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @file
4
 * Administration-related forms and such.
5
 */
6
use OPCache\OPCache;
7
8
/**
9
 * Form callback for OPcache's administration form.
10
 */
11
function opcache_admin_form($form, &$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...
12
  drupal_set_title(t('OPcache'));
13
  $backends = variable_get('opcache_backends', NULL);
14
  $form['opcache_backends'] = array(
15
    '#type' => 'textarea',
16
    '#title' => t('PHP proxy back-ends'),
17
    '#default_value' => empty($backends) ? '' : implode("\n", $backends),
18
    '#description' => t('If you run PHP behind one or more proxy back-ends, enter the full URLs to the PHP servers here, one per line. Include the protocol, and if clean URLs are not enabled, append &ldquo;index.php?q=&rdquo; to the end. For example, &ldquo;http://127.0.0.1:8080/&rdquo; or &ldquo;https://192.168.0.12/drupal/index.php?q=&rdquo;. If you are not running PHP behind a proxy back-end, leave this field blank.'),
19
    '#weight' => 0,
20
  );
21
  $form['submit'] = array(
22
    '#type' => 'submit',
23
    '#value' => t('Save configuration'),
24
    '#weight' => 990,
25
  );
26
  return $form;
27
}
28
29
/**
30
 * Submit handler for our configuration form.
31
 */
32
function opcache_admin_form_submit($form, $form_state) {
0 ignored issues
show
Unused Code introduced by
The parameter $form 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...
33
  $trimmed = trim($form_state['values']['opcache_backends']);
34
  if (!empty($trimmed)) {
35
    $backends = preg_split("/\r\n|\n|\r/", $form_state['values']['opcache_backends']);
36
  }
37
  else {
38
    $backends = NULL;
39
  }
40
  variable_set('opcache_backends', $backends);
41
  drupal_set_message(t('The configuration options have been saved.'));
42
}
43
44
/**
45
 * Page callback for OPCache status.
46
 */
47
function opcache_admin_status() {
48
  $opcache = new OPCache();
49
  $status = $opcache->status();
50
  $render = array(
51
    'opcache-status' => array(
52
      '#theme' => 'table',
53
      '#rows' => $status,
54
    ),
55
  );
56
  return drupal_render($render);
57
}
58
59
/**
60
 * Page callback for OPCache configuration.
61
 */
62
63
function opcache_admin_config() {
64
  $opcache = new OPCache();
65
  $config = $opcache->config();
66
  $render = array(
67
    'opcache-config' => array(
68
      '#theme' => 'table',
69
      '#rows' => $config,
70
    ),
71
  );
72
  return drupal_render($render);
73
}