diff --git a/migrations/db/20181102014830_cron-command_no_overlap_migration.php b/migrations/db/20181102014830_cron-command_no_overlap_migration.php index ce0a034..880c6c9 100644 --- a/migrations/db/20181102014830_cron-command_no_overlap_migration.php +++ b/migrations/db/20181102014830_cron-command_no_overlap_migration.php @@ -5,6 +5,8 @@ use EE; use EE\Migration\Base; use EE\Model\Cron; +use EE_DOCKER; +use EE\Cron\Utils as Cron_Utils; class NoOverlapMigration extends Base { @@ -51,7 +53,7 @@ public function up() { } } // Fix no-overlap. - EE\Cron\Utils\update_cron_config(); + Cron_Utils\update_cron_config(); } /** @@ -62,6 +64,6 @@ public function up() { public function down() { $this->fs->copy( $this->backup_file, $this->source_file ); - \EE_DOCKER::restart_container( EE_CRON_SCHEDULER ); + EE_DOCKER::restart_container( EE_CRON_SCHEDULER ); } } diff --git a/src/Cron_Command.php b/src/Cron_Command.php index f292ef5..1bd49d3 100644 --- a/src/Cron_Command.php +++ b/src/Cron_Command.php @@ -1,7 +1,9 @@ $cron_id ], $data_to_update ); - EE\Cron\Utils\update_cron_config(); + Cron_Utils\update_cron_config(); EE::success( 'Cron update Successfully' ); - EE\Utils\delem_log( 'ee cron add end' ); + EE_Utils\delem_log( 'ee cron add end' ); } /** @@ -283,10 +285,10 @@ public function update( $args, $assoc_args ) { */ public function _list( $args, $assoc_args ) { - $all = EE\Utils\get_flag_value( $assoc_args, 'all' ); + $all = EE_Utils\get_flag_value( $assoc_args, 'all' ); if ( ( ! isset( $args[0] ) || 'host' !== $args[0] ) && ! $all ) { - $args = auto_site_name( $args, 'cron', 'list' ); + $args = Site_Utils\auto_site_name( $args, 'cron', 'list' ); } if ( isset( $args[0] ) ) { @@ -300,7 +302,7 @@ public function _list( $args, $assoc_args ) { EE::error( 'No cron jobs found.' ); } - EE\Utils\format_items( 'table', $crons, [ 'id', 'site_url', 'command', 'schedule' ] ); + EE_Utils\format_items( 'table', $crons, [ 'id', 'site_url', 'command', 'schedule' ] ); } /** @@ -326,7 +328,7 @@ public function run_now( $args ) { EE::error( 'No such cron with id ' . $args[0] ); } - $container = EE\Cron\Utils\site_php_container( $cron->site_url ); + $container = Cron_Utils\site_php_container( $cron->site_url ); $command = $cron->command; $user = empty( $cron->user ) ? 'root' : $cron->user; @@ -363,7 +365,7 @@ public function delete( $args ) { } $cron->delete(); - EE\Cron\Utils\update_cron_config(); + Cron_Utils\update_cron_config(); EE::success( 'Deleted cron with id ' . $id ); diff --git a/src/helper/utils.php b/src/helper/utils.php index adcc3b5..7d14d26 100644 --- a/src/helper/utils.php +++ b/src/helper/utils.php @@ -4,6 +4,9 @@ use EE; use EE\Model\Cron; +use EE_DOCKER; +use EE\Utils as EE_Utils; +use Mustache_Engine; /** * Generates cron config from DB @@ -12,7 +15,7 @@ function update_cron_config() { $config = generate_cron_config(); file_put_contents( EE_ROOT_DIR . '/services/cron/config.ini', $config ); - \EE_DOCKER::restart_container( EE_CRON_SCHEDULER ); + EE_DOCKER::restart_container( EE_CRON_SCHEDULER ); } /** @@ -25,7 +28,7 @@ function generate_cron_config() { foreach ( $crons as &$cron ) { $job_type = 'host' === $cron->site_url ? 'job-local' : 'job-exec'; - $id = $cron->site_url . '-' . preg_replace( '/[^a-zA-Z0-9\@]/', '-', $cron->command ) . '-' . EE\Utils\random_password( 5 ); + $id = $cron->site_url . '-' . preg_replace( '/[^a-zA-Z0-9\@]/', '-', $cron->command ) . '-' . EE_Utils\random_password( 5 ); $id = preg_replace( '/--+/', '-', $id ); $cron->job_type = $job_type; $cron->id = $id; @@ -35,7 +38,7 @@ function generate_cron_config() { } } - $me = new \Mustache_Engine(); + $me = new Mustache_Engine(); return $me->render( $config_template, $crons ); }