1 | <?php |
||
2 | /** |
||
3 | * @link https://www.yiiframework.com/ |
||
4 | * @copyright Copyright (c) 2008 Yii Software LLC |
||
5 | * @license https://www.yiiframework.com/license/ |
||
6 | */ |
||
7 | |||
8 | namespace yii\widgets; |
||
9 | |||
10 | use Yii; |
||
11 | use yii\base\InvalidConfigException; |
||
12 | use yii\base\Widget; |
||
13 | use yii\data\Sort; |
||
14 | use yii\helpers\Html; |
||
15 | |||
16 | /** |
||
17 | * LinkSorter renders a list of sort links for the given sort definition. |
||
18 | * |
||
19 | * LinkSorter will generate a hyperlink for every attribute declared in [[sort]]. |
||
20 | * |
||
21 | * For more details and usage information on LinkSorter, see the [guide article on sorting](guide:output-sorting). |
||
22 | * |
||
23 | * @author Qiang Xue <[email protected]> |
||
24 | * @since 2.0 |
||
25 | */ |
||
26 | class LinkSorter extends Widget |
||
27 | { |
||
28 | /** |
||
29 | * @var Sort|null the sort definition |
||
30 | */ |
||
31 | public $sort; |
||
32 | /** |
||
33 | * @var array|null list of the attributes that support sorting. If not set, it will be determined |
||
34 | * using [[Sort::attributes]]. |
||
35 | */ |
||
36 | public $attributes; |
||
37 | /** |
||
38 | * @var array HTML attributes for the sorter container tag. |
||
39 | * @see \yii\helpers\Html::ul() for special attributes. |
||
40 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
41 | */ |
||
42 | public $options = ['class' => 'sorter']; |
||
43 | /** |
||
44 | * @var array HTML attributes for the link in a sorter container tag which are passed to [[Sort::link()]]. |
||
45 | * @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered. |
||
46 | * @since 2.0.6 |
||
47 | */ |
||
48 | public $linkOptions = []; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * Initializes the sorter. |
||
53 | */ |
||
54 | 4 | public function init() |
|
55 | { |
||
56 | 4 | parent::init(); |
|
57 | |||
58 | 4 | if ($this->sort === null) { |
|
59 | throw new InvalidConfigException('The "sort" property must be set.'); |
||
60 | } |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * Executes the widget. |
||
65 | * This method renders the sort links. |
||
66 | */ |
||
67 | 3 | public function run() |
|
68 | { |
||
69 | 3 | echo $this->renderSortLinks(); |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * Renders the sort links. |
||
74 | * @return string the rendering result |
||
75 | */ |
||
76 | 3 | protected function renderSortLinks() |
|
77 | { |
||
78 | 3 | $attributes = empty($this->attributes) ? array_keys($this->sort->attributes) : $this->attributes; |
|
79 | 3 | $links = []; |
|
80 | 3 | foreach ($attributes as $name) { |
|
81 | 3 | $links[] = $this->sort->link($name, $this->linkOptions); |
|
0 ignored issues
–
show
|
|||
82 | } |
||
83 | |||
84 | 3 | return Html::ul($links, array_merge($this->options, ['encode' => false])); |
|
85 | } |
||
86 | } |
||
87 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.