PMCORE-3845 Check and made the recommend changes in the Laravel upgrade guide
This commit is contained in:
committed by
Mauricio Veliz
parent
6d1d7d752e
commit
d0c5a23d67
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||
use Illuminate\Queue\Console\RestartCommand as BaseRestartCommand;
|
||||
|
||||
class RestartCommand extends BaseRestartCommand
|
||||
@@ -17,4 +18,15 @@ class RestartCommand extends BaseRestartCommand
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new queue restart command.
|
||||
*
|
||||
* @param Cache $cache
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Cache $cache)
|
||||
{
|
||||
parent::__construct($cache);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,20 +4,23 @@ namespace App\Console\Commands;
|
||||
|
||||
use Bootstrap;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Console\Scheduling\Schedule;
|
||||
use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Contracts\Debug\ExceptionHandler;
|
||||
use Maveriks\WebApplication;
|
||||
use ProcessMaker\Model\TaskScheduler;
|
||||
|
||||
class ScheduleRunCommand extends BaseCommand
|
||||
{
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(\Illuminate\Console\Scheduling\Schedule $schedule)
|
||||
public function __construct()
|
||||
{
|
||||
$this->startedAt = Carbon::now();
|
||||
$this->signature = "schedule:run";
|
||||
@@ -27,18 +30,22 @@ class ScheduleRunCommand extends BaseCommand
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
";
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
parent::__construct($schedule);
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
*
|
||||
* @param Schedule $schedule
|
||||
* @param Dispatcher $dispatcher
|
||||
* @param ExceptionHandler $handler
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHandler $handler)
|
||||
{
|
||||
$that = $this;
|
||||
$workspace = $this->option('workspace');
|
||||
$user = $this->option('user');
|
||||
$user = $this->option('user');
|
||||
if (!empty($workspace)) {
|
||||
$webApplication = new WebApplication();
|
||||
$webApplication->setRootDir($this->option('processmakerPath'));
|
||||
@@ -52,7 +59,7 @@ class ScheduleRunCommand extends BaseCommand
|
||||
$timezone = isset($p->timezone) && $p->timezone != "" ? $p->timezone : date_default_timezone_get();
|
||||
$body = $p->body;
|
||||
if (!$win) {
|
||||
$body = str_replace(" -c"," " . $user . " -c", $p->body);
|
||||
$body = str_replace(" -c", " " . $user . " -c", $p->body);
|
||||
}
|
||||
|
||||
//for init date and finish date parameters
|
||||
@@ -116,6 +123,6 @@ class ScheduleRunCommand extends BaseCommand
|
||||
}
|
||||
}
|
||||
});
|
||||
parent::handle();
|
||||
parent::handle($schedule, $dispatcher, $handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Contracts\Cache\Repository as Cache;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand;
|
||||
use Illuminate\Queue\Events\JobProcessing;
|
||||
@@ -9,7 +10,6 @@ use Illuminate\Queue\Worker;
|
||||
|
||||
class WorkCommand extends BaseWorkCommand
|
||||
{
|
||||
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
@@ -19,7 +19,7 @@ class WorkCommand extends BaseWorkCommand
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Worker $worker)
|
||||
public function __construct(Worker $worker, Cache $cache)
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
@@ -28,7 +28,7 @@ class WorkCommand extends BaseWorkCommand
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct($worker);
|
||||
parent::__construct($worker, $cache);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,14 +62,14 @@ class WorkCommand extends BaseWorkCommand
|
||||
require_once $file;
|
||||
}
|
||||
//load the classes of the plugins when is required dynamically.
|
||||
$closure = function($className) {
|
||||
$closure = function ($className) {
|
||||
if (class_exists($className)) {
|
||||
return;
|
||||
}
|
||||
if (!defined('PATH_PLUGINS')) {
|
||||
return;
|
||||
}
|
||||
$searchFiles = function($path) use(&$searchFiles, $className) {
|
||||
$searchFiles = function ($path) use (&$searchFiles, $className) {
|
||||
$directories = File::directories($path);
|
||||
foreach ($directories as $directory) {
|
||||
$omittedDirectories = [
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Helpers\Workspace;
|
||||
use App\Console\Commands\WorkCommand;
|
||||
use App\Log\LogManager;
|
||||
use Illuminate\Queue\Worker;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
@@ -17,8 +18,11 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
App::bind('workspace', function() {
|
||||
return new Workspace();
|
||||
$this->app->bind(WorkCommand::class, function ($app) {
|
||||
$isDownForMaintenance = function () {
|
||||
return $this->app->isDownForMaintenance();
|
||||
};
|
||||
return new WorkCommand(App::make(Worker::class, ['isDownForMaintenance' => $isDownForMaintenance]), $app['cache.store']);
|
||||
});
|
||||
|
||||
$this->app->singleton('log', function ($app) {
|
||||
|
||||
Reference in New Issue
Block a user