1
1
<?php
2
2
3
- /*
4
- * This file is part of the PHPCR Shell package
5
- *
6
- * (c) Daniel Leech <[email protected] >
7
- *
8
- * For the full copyright and license information, please view the LICENSE
9
- * file that was distributed with this source code.
10
- */
11
-
12
3
namespace PHPCR \Shell \Subscriber ;
13
4
14
5
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
15
6
use PHPCR \Shell \Event \PhpcrShellEvents ;
16
7
use PHPCR \Shell \Event \ProfileInitEvent ;
17
- use Symfony \Component \Console \Helper \QuestionHelper ;
8
+ use Symfony \Component \Console \Helper \DialogHelper ;
18
9
use PHPCR \Shell \Config \ProfileLoader ;
19
10
use Symfony \Component \Console \Output \OutputInterface ;
20
11
use PHPCR \Shell \Config \Profile ;
21
12
22
13
class ProfileLoaderSubscriber implements EventSubscriberInterface
23
14
{
24
15
protected $ profileLoader ;
25
- protected $ questionHelper ;
16
+ protected $ dialogHelper ;
26
17
27
18
public static function getSubscribedEvents ()
28
19
{
@@ -31,10 +22,10 @@ public static function getSubscribedEvents()
31
22
);
32
23
}
33
24
34
- public function __construct (ProfileLoader $ profileLoader , $ questionHelper )
25
+ public function __construct (ProfileLoader $ profileLoader , $ dialogHelper )
35
26
{
36
27
$ this ->profileLoader = $ profileLoader ;
37
- $ this ->questionHelper = $ questionHelper ;
28
+ $ this ->dialogHelper = $ dialogHelper ;
38
29
}
39
30
40
31
public function handleProfileInit (ProfileInitEvent $ e )
@@ -82,13 +73,15 @@ public function handleProfileInit(ProfileInitEvent $e)
82
73
$ output ->writeln ('<info>No connection parameters, given. Select an existing profile:</info> ' );
83
74
$ output ->writeln ('' );
84
75
76
+ foreach ($ profileNames as $ i => $ profileName ) {
77
+ $ output ->writeln (sprintf (' (%d) <comment>%s</comment> ' , $ i , $ profileName ));
78
+ }
79
+
80
+ $ output ->writeln ('' );
81
+
85
82
$ selectedName = null ;
86
83
while (null === $ selectedName ) {
87
- $ number = $ this ->questionHelper ->select (
88
- $ output ,
89
- '<info>Choose a profile</info>: ' ,
90
- $ profileNames
91
- );
84
+ $ number = $ this ->dialogHelper ->ask ($ output , '<info>Enter profile number</info>: ' );
92
85
93
86
if (!isset ($ profileNames [$ number ])) {
94
87
$ output ->writeln ('<error>Invalid selection!</error> ' );
0 commit comments