@@ -107,34 +107,19 @@ public function init()
107107 $ this ->initialized = true ;
108108 }
109109
110- /**
111- * Initialize the supported transports.
112- */
113- private function initializeTransports ()
114- {
115- $ transports = array (
116- new \PHPCR \Shell \Transport \DoctrineDbal ($ this ->sessionInput ),
117- new \PHPCR \Shell \Transport \Jackrabbit ($ this ->sessionInput ),
118- );
119-
120- foreach ($ transports as $ transport ) {
121- $ this ->transports [$ transport ->getName ()] = $ transport ;;
122- }
123- }
124-
125110 /**
126111 * Register the helpers required by the application
127112 */
128113 private function registerHelpers ()
129114 {
130115 $ helpers = array (
131116 new ConfigHelper (),
132- new EditorHelper ($ this ->session ),
133- new NodeHelper ($ this ->session ),
134- new PathHelper ($ this ->session ),
117+ new EditorHelper ($ this ->getSession () ),
118+ new NodeHelper ($ this ->getSession () ),
119+ new PathHelper ($ this ->getSession () ),
135120 new PhpcrConsoleDumperHelper (),
136- new PhpcrHelper ($ this ->session ),
137- new RepositoryHelper ($ this ->session ->getRepository ()),
121+ new PhpcrHelper ($ this ->getSession () ),
122+ new RepositoryHelper ($ this ->getSession () ->getRepository ()),
138123 new ResultFormatterHelper (),
139124 new TextHelper (),
140125 );
@@ -235,81 +220,6 @@ private function registerEventListeners()
235220 $ this ->dispatcher ->addSubscriber (new Subscriber \AliasSubscriber ($ this ->getHelperSet ()->get ('config ' )));
236221 }
237222
238- /**
239- * Initialize the PHPCR session
240- */
241- private function initSession ()
242- {
243- $ transport = $ this ->getTransport ();
244- $ repository = $ transport ->getRepository ();
245- $ credentials = new SimpleCredentials (
246- $ this ->sessionInput ->getOption ('phpcr-username ' ),
247- $ this ->sessionInput ->getOption ('phpcr-password ' )
248- );
249-
250- $ session = $ repository ->login ($ credentials , $ this ->sessionInput ->getOption ('phpcr-workspace ' ));
251-
252- if (!$ this ->session ) {
253- $ this ->session = new PhpcrSession ($ session );
254- } else {
255- $ this ->session ->setPhpcrSession ($ session );
256- }
257- }
258-
259- /**
260- * Change the current workspace
261- *
262- * @todo: Move to session helper?
263- *
264- * @param string $workspaceName
265- */
266- public function changeWorkspace ($ workspaceName )
267- {
268- $ this ->session ->logout ();
269- $ this ->sessionInput ->setOption ('phpcr-workspace ' , $ workspaceName );
270- $ this ->initSession ($ this ->sessionInput );
271- }
272-
273- /**
274- * Login (again)
275- *
276- * @todo: Move to session helper
277- *
278- * @param string $username
279- * @param string $password
280- * @param string $workspaceName
281- */
282- public function relogin ($ username , $ password , $ workspaceName = null )
283- {
284- $ this ->session ->logout ();
285- $ this ->sessionInput ->setOption ('phpcr-username ' , $ username );
286- $ this ->sessionInput ->setOption ('phpcr-password ' , $ password );
287-
288- if ($ workspaceName ) {
289- $ this ->sessionInput ->setOption ('phpcr-workspace ' , $ workspaceName );
290- }
291- $ this ->initSession ($ this ->sessionInput );
292- }
293-
294- /**
295- * Return the transport as defined in the sessionInput
296- */
297- private function getTransport ()
298- {
299- $ transportName = $ this ->sessionInput ->getOption ('transport ' );
300-
301- if (!isset ($ this ->transports [$ transportName ])) {
302- throw new \InvalidArgumentException (sprintf (
303- 'Unknown transport "%s", I have "%s" ' ,
304- $ transportName , implode (', ' , array_keys ($ this ->transports ))
305- ));
306- }
307-
308- $ transport = $ this ->transports [$ transportName ];
309-
310- return $ transport ;
311- }
312-
313223 /**
314224 * Configure the output formatter
315225 */
0 commit comments