1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Charcoal\Admin\Widget; |
4
|
|
|
|
5
|
|
|
// From `charcoal-core` |
6
|
|
|
use Charcoal\Model\ModelInterface; |
7
|
|
|
|
8
|
|
|
// From `charcoal-property` |
9
|
|
|
use Charcoal\Property\PropertyInterface; |
10
|
|
|
|
11
|
|
|
// From `charcoal-object` |
12
|
|
|
use Charcoal\Object\HierarchicalCollection; |
13
|
|
|
|
14
|
|
|
// From `charcoal-admin` |
15
|
|
|
use Charcoal\Admin\Property\Display\HierarchicalDisplay; |
16
|
|
|
use Charcoal\Admin\Widget\TableWidget; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The hierarchical table widget displays a collection in a tabular (table) format. |
20
|
|
|
*/ |
21
|
|
|
class HierarchicalTableWidget extends TableWidget |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Provide a template to fullfill UIItem interface. |
25
|
|
|
* |
26
|
|
|
* @return string |
27
|
|
|
*/ |
28
|
|
|
public function template() |
29
|
|
|
{ |
30
|
|
|
return 'charcoal/admin/widget/table'; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Setup the property's display value before its assigned to the object row. |
35
|
|
|
* |
36
|
|
|
* This method is useful for classes using this trait. |
37
|
|
|
* |
38
|
|
|
* @param ModelInterface $object The current row's object. |
39
|
|
|
* @param PropertyInterface $property The current property. |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
protected function setupDisplayPropertyValue( |
43
|
|
|
ModelInterface $object, |
44
|
|
|
PropertyInterface $property |
45
|
|
|
) { |
46
|
|
|
parent::setupDisplayPropertyValue($object, $property); |
47
|
|
|
|
48
|
|
|
if ($this->display instanceof HierarchicalDisplay) { |
49
|
|
|
$this->display->setCurrentLevel($object->hierarchyLevel()); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Sort the objects before they are displayed as rows. |
55
|
|
|
* |
56
|
|
|
* @see \Charcoal\Admin\Ui\CollectionContainerTrait::sortObjects() |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
public function sortObjects() |
60
|
|
|
{ |
61
|
|
|
$collection = new HierarchicalCollection($this->objects(), false); |
62
|
|
|
$collection |
63
|
|
|
->setPage($this->page()) |
64
|
|
|
->setNumPerPage($this->numPerPage()) |
65
|
|
|
->sortTree(); |
66
|
|
|
|
67
|
|
|
return $collection->all(); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
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.