1 | <?php |
||
27 | class TreeCommandHandler |
||
28 | { |
||
29 | /** |
||
30 | * Prefix string for child resources. |
||
31 | * |
||
32 | * @internal |
||
33 | */ |
||
34 | const CHILD_PREFIX = '├── '; |
||
35 | |||
36 | /** |
||
37 | * Prefix string for the last child resource of a parent resource. |
||
38 | * |
||
39 | * @internal |
||
40 | */ |
||
41 | const LAST_CHILD_PREFIX = '└── '; |
||
42 | |||
43 | /** |
||
44 | * Prefix for nested resources when an ancestor resource is open. |
||
45 | * |
||
46 | * @internal |
||
47 | */ |
||
48 | const NESTING_OPEN_PREFIX = '│ '; |
||
49 | |||
50 | /** |
||
51 | * Prefix for nested resources when no ancestor resource is open. |
||
52 | * |
||
53 | * @internal |
||
54 | */ |
||
55 | const NESTING_CLOSED_PREFIX = ' '; |
||
56 | |||
57 | /** |
||
58 | * @var ResourceRepository |
||
59 | */ |
||
60 | private $repo; |
||
61 | |||
62 | /** |
||
63 | * @var string |
||
64 | */ |
||
65 | private $currentPath = '/'; |
||
66 | |||
67 | /** |
||
68 | * Creates the handler. |
||
69 | * |
||
70 | * @param ResourceRepository $repo The resource repository. |
||
71 | */ |
||
72 | 3 | public function __construct(ResourceRepository $repo) |
|
76 | |||
77 | /** |
||
78 | * Handles the "tree" command. |
||
79 | * |
||
80 | * @param Args $args The console arguments. |
||
81 | * @param IO $io The I/O. |
||
82 | * |
||
83 | * @return int The status code. |
||
84 | */ |
||
85 | 3 | public function handle(Args $args, IO $io) |
|
101 | |||
102 | /** |
||
103 | * Recursively prints the tree for the given resource. |
||
104 | * |
||
105 | * @param IO $io The I/O. |
||
106 | * @param PuliResource $resource The printed resource. |
||
107 | * @param int $total Collects the total number of printed resources. |
||
108 | * @param string $prefix The prefix for all printed resources. |
||
109 | */ |
||
110 | 3 | private function printTree(IO $io, PuliResource $resource, &$total, $prefix = '') |
|
136 | } |
||
137 |