/**
  * Settings and save Task
  *
  * @param Task $task
  * @param User $user
  * @param Node $node
  * @param array $testsIds
  * @return Task
  */
 private function _settingTask(Task $task, User $user, Node $node, array $testsIds) : Task
 {
     $task->setNode($node);
     $task->setTestIds($testsIds);
     $task->setUser($user);
     $entityManager = $this->getDoctrine()->getManager();
     $dispatcher = $this->get('event_dispatcher');
     $event = new TaskEvent($task);
     $task = $dispatcher->dispatch('test.save_task_settings', $event)->getTask();
     $entityManager->persist($task);
     $entityManager->flush();
     return $task;
 }