@@ -15,7 +15,7 @@ Building a Tree from an Array
15
15
You can build a tree from an array by passing the array to the :method: `Symfony\\ Component\\ Console\\ Helper\\ TreeHelper::createTree `
16
16
method::
17
17
18
- use Symfony\\ Component\\ Console\\ Helper\ \TreeHelper;
18
+ use Symfony\Component\Console\Helper\TreeHelper;
19
19
20
20
$tree = TreeHelper::createTree($io, null, [
21
21
'src' => [
@@ -44,27 +44,25 @@ The above code will output the following tree:
44
44
βββ templates
45
45
βββ base.html.twig
46
46
47
-
48
47
Manually Creating a Tree
49
48
~~~~~~~~~~~~~~~~~~~~~~~~
50
49
51
50
You can manually create a tree by creating a new instance of the :class: `Symfony\\ Component\\ Console\\ Helper\\ Tree ` class and adding nodes to it::
52
51
53
- use Symfony\\ Component\\ Console\\ Helper\\ Tree;
54
- use Symfony\\ Component\\ Console\\ Helper\ \TreeHelper;
52
+ use Symfony\Component\Console\Helper\Tree
53
+ use Symfony\Component\Console\Helper\TreeHelper;
55
54
56
- $tree = new Tree($io);
57
- $tree->add('src', [
55
+ $node = TreeNode::fromValues([
58
56
'Command',
59
57
'Controller' => [
60
58
'DefaultController.php',
61
59
],
62
60
'Kernel.php',
63
61
]);
64
- $tree ->add('templates', [
62
+ $node ->add('templates', [
65
63
'base.html.twig',
66
64
]);
67
-
65
+ $tree = TreeHelper::createTree($io, $node);
68
66
$tree->render();
69
67
70
68
Customizing the Tree Style
@@ -200,8 +198,8 @@ Making a Custom Tree Style
200
198
You can create your own tree style by passing the characters to the constructor
201
199
of the :class: `Symfony\\ Component\\ Console\\ Helper\\ TreeStyle ` class::
202
200
203
- use Symfony\\ Component\\ Console\\ Helper\ \TreeHelper;
204
- use Symfony\\ Component\\ Console\\ Helper\ \TreeStyle;
201
+ use Symfony\Component\Console\Helper\TreeHelper;
202
+ use Symfony\Component\Console\Helper\TreeStyle;
205
203
206
204
$customStyle = new TreeStyle('π£ ', 'π ', 'π΅ ', 'π’ ', 'π΄ ', 'π‘ ');
207
205
@@ -224,7 +222,7 @@ of the :class:`Symfony\\Component\\Console\\Helper\\TreeStyle` class::
224
222
225
223
The above code will output the following tree:
226
224
227
- ..code-block:: text
225
+ .. code-block :: text
228
226
229
227
π΅ π£ π‘ src
230
228
π΅ π’ π£ π‘ Command
0 commit comments