[ 'prefix' => 'w', 'longPrefix' => 'whitelist', 'cast' => 'string', 'required' => true, 'description' => 'The whitelist of task_name that can be restarted.' ], 'queue' => [ 'prefix' => 'q', 'longPrefix' => 'queue', 'cast' => 'string', 'required' => true, 'description' => 'The queue to consider in the scope.' ], 'statuses' => [ 'prefix' => 's', 'longPrefix' => 'statuses', 'cast' => 'string', 'required' => false, 'description' => 'The task log statuses to consider stuck', 'defaultValue' => TaskLog::STATUS_ENQUEUED ], 'age' => [ 'prefix' => 'w', 'longPrefix' => 'age', 'cast' => 'int', 'required' => false, 'defaultValue' => StuckTaskRepository::MIN_AGE, 'description' => 'Age in seconds of a task log.' ] ]; } protected function getQuery(): StuckTaskQuery { return new StuckTaskQuery( $this->getOption('queue'), explode(',', (string)$this->getOption('whitelist')), explode(',', (string)$this->getOption('statuses')), $this->getOption('age') ); } protected function findStuckTasks(): StuckTaskCollection { return $this->getStuckTasksRepository()->findAll($this->getQuery()); } private function getStuckTasksRepository(): StuckTaskRepository { return $this->getServiceLocator()->get(StuckTaskRepository::class); } }