Completed
Push — 7.x-1.x ( 2f9e3c...1070be )
by Frédéric G.
01:36
created

Overrides::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Drupal\qa\Plugin\Qa\Control\Views;
4
5
class Overrides extends Views {
6
7
  /**
8
   * {@inheritdoc]
9
   */
10
  public function init() {
11
    $this->package_name = __NAMESPACE__;
12
    $this->title = t('Non-default views');
13
    $this->description = t('Have any views been overridden or only created in the DB ? This is a performance and change management issue.');
14
  }
15
16
  function checkViewType($view) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
17
    $status = $view->type == t('Default') ? 1 : 0;
18
    if (!$status) {
19
      $name = empty($view->human_name) ? $view->name : $view->human_name;
20
      $result = array(
21
          module_exists('views_ui')
22
          ? l($name, "admin/structure/views/view/{$view->name}/edit")
23
          : $name,
24
          $view->type);
25
    }
26
    else {
27
      $result = NULL;
28
    }
29
    $ret = array(
30
      'name'   => $view->name,
31
      'status' => $status,
32
      'result' => $result,
33
    );
34
    return $ret;
35
  }
36
37
  function run() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
38
    $pass = parent::run();
39
    $views = views_get_all_views(TRUE);
40
    foreach ($views as $view) {
41
      $pass->record($this->checkViewType($view));
42
    }
43
    $pass->life->end();
44
45
    // Prepare for theming
46
    $result = array();
47
    // @XXX May be inconsistent with non-BMP strings ?
48
    uksort($pass->result, 'strcasecmp');
49
    foreach ($pass->result as $view_report) {
50
      $result[] = t('!view: @type', array(
51
        '!view' => $view_report[0], // Built safe in self::checkViewPhp
52
        '@type' => $view_report[1],
53
      ));
54
    }
55
    $result = theme('item_list', array('items' => $result));
56
    $pass->result = $result;
57
    return $pass;
58
  }
59
}
60