11<?php
22
3- /*
4- * This file is part of the PHPCR Shell package
5- *
6- * (c) Daniel Leech <daniel@dantleech.com>
7- *
8- * For the full copyright and license information, please view the LICENSE
9- * file that was distributed with this source code.
10- */
11-
123namespace PHPCR \Shell \Subscriber ;
134
145use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
156use PHPCR \Shell \Event \PhpcrShellEvents ;
167use PHPCR \Shell \Event \ProfileInitEvent ;
17- use Symfony \Component \Console \Helper \QuestionHelper ;
8+ use Symfony \Component \Console \Helper \DialogHelper ;
189use PHPCR \Shell \Config \ProfileLoader ;
1910use Symfony \Component \Console \Output \OutputInterface ;
2011use PHPCR \Shell \Config \Profile ;
2112
2213class ProfileLoaderSubscriber implements EventSubscriberInterface
2314{
2415 protected $ profileLoader ;
25- protected $ questionHelper ;
16+ protected $ dialogHelper ;
2617
2718 public static function getSubscribedEvents ()
2819 {
@@ -31,10 +22,10 @@ public static function getSubscribedEvents()
3122 );
3223 }
3324
34- public function __construct (ProfileLoader $ profileLoader , $ questionHelper )
25+ public function __construct (ProfileLoader $ profileLoader , $ dialogHelper )
3526 {
3627 $ this ->profileLoader = $ profileLoader ;
37- $ this ->questionHelper = $ questionHelper ;
28+ $ this ->dialogHelper = $ dialogHelper ;
3829 }
3930
4031 public function handleProfileInit (ProfileInitEvent $ e )
@@ -82,13 +73,15 @@ public function handleProfileInit(ProfileInitEvent $e)
8273 $ output ->writeln ('<info>No connection parameters, given. Select an existing profile:</info> ' );
8374 $ output ->writeln ('' );
8475
76+ foreach ($ profileNames as $ i => $ profileName ) {
77+ $ output ->writeln (sprintf (' (%d) <comment>%s</comment> ' , $ i , $ profileName ));
78+ }
79+
80+ $ output ->writeln ('' );
81+
8582 $ selectedName = null ;
8683 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>: ' );
9285
9386 if (!isset ($ profileNames [$ number ])) {
9487 $ output ->writeln ('<error>Invalid selection!</error> ' );
0 commit comments