@@ -56,11 +56,11 @@ class ShellApplication extends Application
5656 *
5757 * {@inheritDoc}
5858 */
59- public function __construct ($ name = ' UNKNOWN ' , $ version = ' UNKNOWN ' )
59+ public function __construct ()
6060 {
61- parent ::__construct ($ name , $ version );
61+ parent ::__construct (SessionApplication:: APP_NAME , SessionApplication:: APP_VERSION );
6262 $ this ->profile = new Profile ();
63- $ this ->dispatcher = new EventDispatcher ();
63+ $ this ->setDispatcher ( $ this -> dispatcher = new EventDispatcher () );
6464 $ this ->transportRegistry = new TransportRegistry ();
6565 $ this ->registerTransports ();
6666 $ this ->registerHelpers ();
@@ -101,14 +101,18 @@ public function setShowUnsupported($boolean)
101101 * Note that we do this "lazily" because we instantiate the ShellApplication early,
102102 * before the SessionInput has been set. The SessionInput must be set before we
103103 * can initialize the application.
104+ *
105+ * @todo: The above scenario is no longer true, we use a Profile. So maybe it can
106+ * be refactored.
104107 */
105108 public function init ()
106109 {
107110 if (true === $ this ->initialized ) {
108111 return ;
109112 }
110113
111- $ this ->registerCommands ();
114+ $ this ->registerPhpcrCommands ();
115+ $ this ->registerShellCommands ();
112116
113117 $ event = new ApplicationInitEvent ($ this );
114118 $ this ->dispatcher ->dispatch (PhpcrShellEvents::APPLICATION_INIT , $ event );
@@ -119,7 +123,7 @@ public function init()
119123 /**
120124 * Register the helpers required by the application
121125 */
122- private function registerHelpers ()
126+ protected function registerHelpers ()
123127 {
124128 $ phpcrHelper = new PhpcrHelper ($ this ->transportRegistry , $ this ->profile );
125129
@@ -143,7 +147,7 @@ private function registerHelpers()
143147 /**
144148 * Register the commands used in the shell
145149 */
146- private function registerCommands ()
150+ protected function registerPhpcrCommands ()
147151 {
148152 // phpcr commands
149153 $ this ->add (new CommandPhpcr \AccessControlPrivilegeListCommand ());
@@ -217,7 +221,10 @@ private function registerCommands()
217221 $ this ->add (new CommandPhpcr \LockTokenListCommand ());
218222 $ this ->add (new CommandPhpcr \LockTokenRemoveCommand ());
219223 $ this ->add (new CommandPhpcr \LockUnlockCommand ());
224+ }
220225
226+ protected function registerShellCommands ()
227+ {
221228 // add shell-specific commands
222229 $ this ->add (new CommandShell \AliasListCommand ());
223230 $ this ->add (new CommandShell \ConfigInitCommand ());
@@ -227,7 +234,7 @@ private function registerCommands()
227234 $ this ->add (new CommandShell \ExitCommand ());
228235 }
229236
230- private function registerEventListeners ()
237+ protected function registerEventListeners ()
231238 {
232239 $ this ->dispatcher ->addSubscriber (new Subscriber \ProfileFromSessionInputSubscriber ());
233240 $ this ->dispatcher ->addSubscriber (new Subscriber \ProfileWriterSubscriber (
@@ -293,7 +300,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
293300 $ input = $ event ->getInput ();
294301
295302 if (!$ name ) {
296- $ input = new ArrayInput (array ('command ' => ' shell:path:show ' ));
303+ $ input = new ArrayInput (array ('command ' => $ this -> getDefaultCommand () ));
297304 }
298305
299306 try {
@@ -307,6 +314,14 @@ public function doRun(InputInterface $input, OutputInterface $output)
307314 return $ exitCode ;
308315 }
309316
317+ /**
318+ * Return the default command
319+ */
320+ protected function getDefaultCommand ()
321+ {
322+ return 'shell:path:show ' ;
323+ }
324+
310325 /**
311326 * Render an exception to the console
312327 *
0 commit comments