@@ -583,6 +583,24 @@ public function getDrushPort()
583583 }
584584 }
585585
586+ /**
587+ * Get's the exposed port of the Drupal Console container.
588+ *
589+ * @return bool|mixed
590+ */
591+ public function getDrupalConsolePort ()
592+ {
593+ $ process = new Process ('docker-compose port console 22 ' , $ this ->getDockerComposePath ());
594+ $ process ->run ();
595+ if (!$ process ->isSuccessful ()) {
596+ return false ;
597+ } else {
598+ $ output_array = explode (': ' , trim ($ process ->getOutput ()));
599+ return array_pop ($ output_array );
600+ }
601+ }
602+
603+
586604 /**
587605 * Get the system URL of an environment.
588606 *
@@ -647,6 +665,39 @@ public function writeDrushAlias()
647665 }
648666 }
649667
668+ /**
669+ * Writes a local Drupal Console site file.
670+ */
671+ public function writeConsoleSiteTargets ()
672+ {
673+ $ console_target_file_path = "{$ _SERVER ['HOME ' ]}/.console/sites/terra. {$ this ->app ->name }.yml " ;
674+
675+ $ console_target_file = array ();
676+ $ console_target_file [] = '' ;
677+
678+ foreach ($ this ->app ->environments as $ environment_name => $ environment ) {
679+ $ factory = new self ($ environment , $ this ->app );
680+ $ path = "/source/ " . $ environment ['document_root ' ];
681+ $ console_target_file [] = '# DO NOT EDIT. This is generated by Terra. Any changes will be overridden when the environment is re-enabled. ' ;
682+ $ console_target_file [] = "{$ environment_name }: " ;
683+ $ console_target_file [] = " host: {$ factory ->getHost ()}" ;
684+ $ console_target_file [] = " root: $ path " ;
685+ $ console_target_file [] = " user: root " ;
686+ $ console_target_file [] = " port: {$ factory ->getDrupalConsolePort ()}" ;
687+ $ console_target_file [] = '' ;
688+ }
689+
690+ $ fs = new FileSystem ();
691+
692+ try {
693+ $ fs ->dumpFile ($ console_target_file_path , implode ("\n" , $ console_target_file ));
694+
695+ return true ;
696+ } catch (IOException $ e ) {
697+ return false ;
698+ }
699+ }
700+
650701 /**
651702 * Get the name of the drush alias.
652703 */
0 commit comments