1212 */
1313
1414use EE \Utils ;
15+ use EE \Model \Site ;
1516
1617class Shell_Command extends EE_Command {
1718
@@ -25,15 +26,16 @@ class Shell_Command extends EE_Command {
2526 */
2627 public function __invoke ( $ args ) {
2728 EE \Utils \delem_log ( 'ee shell start ' );
28- $ args = EE \Utils \set_site_arg ( $ args , 'shell ' );
29+ $ args = EE \SiteUtils \auto_site_name ( $ args , 'shell ' , ' ' );
2930 $ site_name = EE \Utils \remove_trailing_slash ( $ args [0 ] );
30- if ( EE :: db ():: site_in_db ( $ site_name ) ) {
31- $ db_select = EE :: db ():: select ( [ ' site_path ' ], [ ' sitename ' => $ site_name ] );
32- $ site_root = $ db_select [ 0 ][ ' site_path ' ];
33- } else {
34- EE ::error ( "Site $ site_name does not exist. " );
31+
32+ $ site = Site:: find ( $ site_name , [ ' site_enabled ' , ' site_fs_path ' ] );
33+
34+ if ( ! $ site || ! $ site -> site_enabled ) {
35+ EE ::error ( "Site $ site_name does not exist or is not enabled . " );
3536 }
36- chdir ($ site_root );
37+
38+ chdir ( $ site ->site_fs_path );
3739 $ this ->run ( "docker-compose exec --user='www-data' php bash " );
3840 EE \Utils \delem_log ( 'ee shell end ' );
3941 }
@@ -43,9 +45,9 @@ private function run( $cmd, $descriptors = null ) {
4345 if ( ! $ descriptors ) {
4446 $ descriptors = array ( STDIN , STDOUT , STDERR );
4547 }
46-
48+
4749 $ final_cmd = EE \Utils \force_env_on_nix_systems ( $ cmd );
48- $ proc = EE \Utils \proc_open_compat ( $ final_cmd , $ descriptors , $ pipes );
50+ $ proc = EE \Utils \proc_open_compat ( $ final_cmd , $ descriptors , $ pipes );
4951 if ( ! $ proc ) {
5052 exit ( 1 );
5153 }
0 commit comments