Completed
Push — master ( cdfa80...308a3c )
by Alexey
18:18
created

Dashboard::moduleHref()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 4
nop 3
dl 0
loc 10
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Dashboard module
5
 *
6
 * @author Alexey Krupskiy <[email protected]>
7
 * @link http://inji.ru/
8
 * @copyright 2015 Alexey Krupskiy
9
 * @license https://github.com/injitools/cms-Inji/blob/master/LICENSE
10
 */
11
class Dashboard extends Module {
12
13
  public function itemHref($item, $col, $colParam) {
14
    $modelName = $item->model;
15
    $relItem = $modelName::get($item->$col);
16
    if ($relItem) {
17
      return "<a href='/admin/" . $relItem->genViewLink() . "'>" . $relItem->name() . "</a>";
18
    }
19
    return 'Ресурс удален';
20
  }
21
22
  public function moduleHref($item, $col, $colParam) {
0 ignored issues
show
Unused Code introduced by
The parameter $colParam 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...
23
    if (!$item->$col) {
24
      return 'Модуль не задан';
25
    }
26
    if (!Module::installed($item->$col, \App::$primary)) {
27
      return 'Модуль ' . $item->$col . ' не установлен';
28
    }
29
    $moduleInfo = Module::getInfo($item->$col);
30
    return !empty($moduleInfo['name']) ? $moduleInfo['name'] : $item->$col;
31
  }
32
33
  public function modelHref($item, $col, $colParam) {
0 ignored issues
show
Unused Code introduced by
The parameter $colParam 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...
34
    if (!$item->$col) {
35
      return 'Модель не задана';
36
    }
37
    if (!class_exists($item->$col)) {
38
      return 'Модель ' . $item->$col . ' несуществует';
39
    }
40
    $modelName = $item->$col;
41
    return $modelName::$objectName ? $modelName::$objectName : $modelName;
42
  }
43
44
}
45