public function testGetTaskCrontabLine() { $task = TaskMock::createNew(); $task->setStatus(TaskInterface::TASK_STATUS_INACTIVE); $task->setCommand('Class::method()'); $task->setComment('comment'); $task->setTime('* * * * *'); $export = TaskManager::getTaskCrontabLine($task, 'path', 'php', 'index.php'); $this->assertEquals("#comment\n#* * * * * cd path; php index.php Class method 2>&1 > /dev/null\n", $export); }
public function actionExportTasks() { if (isset($_POST['folder'])) { $tasks = Task::getList(); $result = []; foreach ($tasks as $t) { $line = TaskManager::getTaskCrontabLine($t, $_POST['folder'], $_POST['php'], $_POST['file']); $result[] = nl2br($line); } echo json_encode($result); } }