From 976c1017a106be73bc8d304faa4f6956df971327 Mon Sep 17 00:00:00 2001 From: Riddhesh Sanghvi Date: Wed, 22 Aug 2018 11:41:10 +0530 Subject: [PATCH] Update variable name Signed-off-by: Riddhesh Sanghvi --- src/Admin_Tools_Command.php | 52 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Admin_Tools_Command.php b/src/Admin_Tools_Command.php index bc5b9fe..6b16d86 100644 --- a/src/Admin_Tools_Command.php +++ b/src/Admin_Tools_Command.php @@ -29,9 +29,9 @@ class Admin_Tools_Command extends EE_Command { private $fs; /** - * @var array $db Object containing essential site related information. + * @var array $site_data Object containing essential site related information. */ - private $db; + private $site_data; public function __construct() { @@ -60,7 +60,7 @@ public function install() { if ( empty( $tools_file ) ) { EE::error( 'admin-tools file is empty. Can\'t proceed further.' ); } - $tools = json_decode( $tools_file, true ); + $tools = json_decode( $tools_file, true ); $json_error = json_last_error(); if ( $json_error != JSON_ERROR_NONE ) { EE::debug( 'Json last error: ' . $json_error ); @@ -100,25 +100,25 @@ public function install() { public function up( $args, $assoc_args ) { EE\Utils\delem_log( 'admin-tools ' . __FUNCTION__ . ' start' ); - $args = EE\SiteUtils\auto_site_name( $args, $this->command, __FUNCTION__ ); - $force = EE\Utils\get_flag_value( $assoc_args, 'force' ); - $this->db = Site::find( EE\Utils\remove_trailing_slash( $args[0] ) ); - if ( ! $this->db || ! $this->db->site_enabled ) { + $args = EE\SiteUtils\auto_site_name( $args, $this->command, __FUNCTION__ ); + $force = EE\Utils\get_flag_value( $assoc_args, 'force' ); + $this->site_data = Site::find( EE\Utils\remove_trailing_slash( $args[0] ) ); + if ( ! $this->site_data || ! $this->site_data->site_enabled ) { EE::error( sprintf( 'Site %s does not exist / is not enabled.', $args[0] ) ); } - if ( $this->db->admin_tools && ! $force ) { - EE::error( sprintf( 'admin-tools already seem to be enabled for %s', $this->db->site_url ) ); + if ( $this->site_data->admin_tools && ! $force ) { + EE::error( sprintf( 'admin-tools already seem to be enabled for %s', $this->site_data->site_url ) ); } - chdir( $this->db->site_fs_path ); + chdir( $this->site_data->site_fs_path ); $launch = EE::launch( 'docker-compose config --services' ); $services = explode( PHP_EOL, trim( $launch->stdout ) ); $min_req_services = [ 'nginx', 'php' ]; if ( count( array_intersect( $services, $min_req_services ) ) !== count( $min_req_services ) ) { - EE::error( sprintf( '%s site-type of %s-command does not support admin-tools.', $this->db->app_sub_type, $this->db->site_type ) ); + 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 ) ); } if ( ! $this->is_installed() ) { @@ -126,14 +126,14 @@ public function up( $args, $assoc_args ) { $this->install(); } - $this->move_config_file( 'docker-compose-admin.mustache', $this->db->site_fs_path . '/docker-compose-admin.yml' ); + $this->move_config_file( 'docker-compose-admin.mustache', $this->site_data->site_fs_path . '/docker-compose-admin.yml' ); if ( EE::exec( 'docker-compose -f docker-compose.yml -f docker-compose-admin.yml up -d nginx' ) ) { - EE::success( sprintf( 'admin-tools enabled for %s site.', $this->db->site_url ) ); - $this->db->admin_tools = 1; - $this->db->save(); + EE::success( sprintf( 'admin-tools enabled for %s site.', $this->site_data->site_url ) ); + $this->site_data->admin_tools = 1; + $this->site_data->save(); } else { - EE::error( sprintf( 'Error in enabling admin-tools for %s site. Check logs.', $this->db->site_url ) ); + EE::error( sprintf( 'Error in enabling admin-tools for %s site. Check logs.', $this->site_data->site_url ) ); } EE\Utils\delem_log( 'admin-tools ' . __FUNCTION__ . ' stop' ); @@ -153,21 +153,21 @@ public function up( $args, $assoc_args ) { public function down( $args, $assoc_args ) { EE\Utils\delem_log( 'admin-tools ' . __FUNCTION__ . ' start' ); - $args = EE\SiteUtils\auto_site_name( $args, $this->command, __FUNCTION__ ); - $force = EE\Utils\get_flag_value( $assoc_args, 'force' ); - $this->db = Site::find( EE\Utils\remove_trailing_slash( $args[0] ) ); - if ( ! $this->db || ! $this->db->site_enabled ) { + $args = EE\SiteUtils\auto_site_name( $args, $this->command, __FUNCTION__ ); + $force = EE\Utils\get_flag_value( $assoc_args, 'force' ); + $this->site_data = Site::find( EE\Utils\remove_trailing_slash( $args[0] ) ); + if ( ! $this->site_data || ! $this->site_data->site_enabled ) { EE::error( sprintf( 'Site %s does not exist / is not enabled.', $args[0] ) ); } - if ( ! $this->db->admin_tools && ! $force ) { - EE::error( sprintf( 'admin-tools already seem to be enabled for %s', $this->db->site_url ) ); + if ( ! $this->site_data->admin_tools && ! $force ) { + EE::error( sprintf( 'admin-tools already seem to be enabled for %s', $this->site_data->site_url ) ); } - EE::docker()::docker_compose_up( $this->db->site_fs_path, [ 'nginx', 'php' ] ); - EE::success( sprintf( 'admin-tools disabled for %s site.', $this->db->site_url ) ); - $this->db->admin_tools = 0; - $this->db->save(); + EE::docker()::docker_compose_up( $this->site_data->site_fs_path, [ 'nginx', 'php' ] ); + EE::success( sprintf( 'admin-tools disabled for %s site.', $this->site_data->site_url ) ); + $this->site_data->admin_tools = 0; + $this->site_data->save(); EE\Utils\delem_log( 'admin-tools ' . __FUNCTION__ . ' stop' ); }