@@ -29,9 +29,9 @@ class Admin_Tools_Command extends EE_Command {
2929 private $ fs ;
3030
3131 /**
32- * @var array $db Object containing essential site related information.
32+ * @var array $site_data Object containing essential site related information.
3333 */
34- private $ db ;
34+ private $ site_data ;
3535
3636 public function __construct () {
3737
@@ -60,7 +60,7 @@ public function install() {
6060 if ( empty ( $ tools_file ) ) {
6161 EE ::error ( 'admin-tools file is empty. Can \'t proceed further. ' );
6262 }
63- $ tools = json_decode ( $ tools_file , true );
63+ $ tools = json_decode ( $ tools_file , true );
6464 $ json_error = json_last_error ();
6565 if ( $ json_error != JSON_ERROR_NONE ) {
6666 EE ::debug ( 'Json last error: ' . $ json_error );
@@ -100,40 +100,40 @@ public function install() {
100100 public function up ( $ args , $ assoc_args ) {
101101
102102 EE \Utils \delem_log ( 'admin-tools ' . __FUNCTION__ . ' start ' );
103- $ args = EE \SiteUtils \auto_site_name ( $ args , $ this ->command , __FUNCTION__ );
104- $ force = EE \Utils \get_flag_value ( $ assoc_args , 'force ' );
105- $ this ->db = Site::find ( EE \Utils \remove_trailing_slash ( $ args [0 ] ) );
106- if ( ! $ this ->db || ! $ this ->db ->site_enabled ) {
103+ $ args = EE \SiteUtils \auto_site_name ( $ args , $ this ->command , __FUNCTION__ );
104+ $ force = EE \Utils \get_flag_value ( $ assoc_args , 'force ' );
105+ $ this ->site_data = Site::find ( EE \Utils \remove_trailing_slash ( $ args [0 ] ) );
106+ if ( ! $ this ->site_data || ! $ this ->site_data ->site_enabled ) {
107107 EE ::error ( sprintf ( 'Site %s does not exist / is not enabled. ' , $ args [0 ] ) );
108108 }
109109
110- if ( $ this ->db ->admin_tools && ! $ force ) {
111- EE ::error ( sprintf ( 'admin-tools already seem to be enabled for %s ' , $ this ->db ->site_url ) );
110+ if ( $ this ->site_data ->admin_tools && ! $ force ) {
111+ EE ::error ( sprintf ( 'admin-tools already seem to be enabled for %s ' , $ this ->site_data ->site_url ) );
112112 }
113113
114- chdir ( $ this ->db ->site_fs_path );
114+ chdir ( $ this ->site_data ->site_fs_path );
115115
116116 $ launch = EE ::launch ( 'docker-compose config --services ' );
117117 $ services = explode ( PHP_EOL , trim ( $ launch ->stdout ) );
118118 $ min_req_services = [ 'nginx ' , 'php ' ];
119119
120120 if ( count ( array_intersect ( $ services , $ min_req_services ) ) !== count ( $ min_req_services ) ) {
121- EE ::error ( sprintf ( '%s site-type of %s-command does not support admin-tools. ' , $ this ->db ->app_sub_type , $ this ->db ->site_type ) );
121+ EE ::error ( sprintf ( '%s site-type of %s-command does not support admin-tools. ' , $ this ->site_data ->app_sub_type , $ this ->site_data ->site_type ) );
122122 }
123123
124124 if ( ! $ this ->is_installed () ) {
125125 EE ::log ( 'It seems admin-tools have not yet been installed. ' );
126126 $ this ->install ();
127127 }
128128
129- $ this ->move_config_file ( 'docker-compose-admin.mustache ' , $ this ->db ->site_fs_path . '/docker-compose-admin.yml ' );
129+ $ this ->move_config_file ( 'docker-compose-admin.mustache ' , $ this ->site_data ->site_fs_path . '/docker-compose-admin.yml ' );
130130
131131 if ( EE ::exec ( 'docker-compose -f docker-compose.yml -f docker-compose-admin.yml up -d nginx ' ) ) {
132- EE ::success ( sprintf ( 'admin-tools enabled for %s site. ' , $ this ->db ->site_url ) );
133- $ this ->db ->admin_tools = 1 ;
134- $ this ->db ->save ();
132+ EE ::success ( sprintf ( 'admin-tools enabled for %s site. ' , $ this ->site_data ->site_url ) );
133+ $ this ->site_data ->admin_tools = 1 ;
134+ $ this ->site_data ->save ();
135135 } else {
136- EE ::error ( sprintf ( 'Error in enabling admin-tools for %s site. Check logs. ' , $ this ->db ->site_url ) );
136+ EE ::error ( sprintf ( 'Error in enabling admin-tools for %s site. Check logs. ' , $ this ->site_data ->site_url ) );
137137 }
138138
139139 EE \Utils \delem_log ( 'admin-tools ' . __FUNCTION__ . ' stop ' );
@@ -153,21 +153,21 @@ public function up( $args, $assoc_args ) {
153153 public function down ( $ args , $ assoc_args ) {
154154
155155 EE \Utils \delem_log ( 'admin-tools ' . __FUNCTION__ . ' start ' );
156- $ args = EE \SiteUtils \auto_site_name ( $ args , $ this ->command , __FUNCTION__ );
157- $ force = EE \Utils \get_flag_value ( $ assoc_args , 'force ' );
158- $ this ->db = Site::find ( EE \Utils \remove_trailing_slash ( $ args [0 ] ) );
159- if ( ! $ this ->db || ! $ this ->db ->site_enabled ) {
156+ $ args = EE \SiteUtils \auto_site_name ( $ args , $ this ->command , __FUNCTION__ );
157+ $ force = EE \Utils \get_flag_value ( $ assoc_args , 'force ' );
158+ $ this ->site_data = Site::find ( EE \Utils \remove_trailing_slash ( $ args [0 ] ) );
159+ if ( ! $ this ->site_data || ! $ this ->site_data ->site_enabled ) {
160160 EE ::error ( sprintf ( 'Site %s does not exist / is not enabled. ' , $ args [0 ] ) );
161161 }
162162
163- if ( ! $ this ->db ->admin_tools && ! $ force ) {
164- EE ::error ( sprintf ( 'admin-tools already seem to be enabled for %s ' , $ this ->db ->site_url ) );
163+ if ( ! $ this ->site_data ->admin_tools && ! $ force ) {
164+ EE ::error ( sprintf ( 'admin-tools already seem to be enabled for %s ' , $ this ->site_data ->site_url ) );
165165 }
166166
167- EE ::docker ()::docker_compose_up ( $ this ->db ->site_fs_path , [ 'nginx ' , 'php ' ] );
168- EE ::success ( sprintf ( 'admin-tools disabled for %s site. ' , $ this ->db ->site_url ) );
169- $ this ->db ->admin_tools = 0 ;
170- $ this ->db ->save ();
167+ EE ::docker ()::docker_compose_up ( $ this ->site_data ->site_fs_path , [ 'nginx ' , 'php ' ] );
168+ EE ::success ( sprintf ( 'admin-tools disabled for %s site. ' , $ this ->site_data ->site_url ) );
169+ $ this ->site_data ->admin_tools = 0 ;
170+ $ this ->site_data ->save ();
171171 EE \Utils \delem_log ( 'admin-tools ' . __FUNCTION__ . ' stop ' );
172172 }
173173
0 commit comments