protected function scheduleTask(TaskInterface $task)
    {
        if (null !== ($execution = $this->taskExecutionRepository->findPending($task))) {
            return;
        }

        if ($task->getInterval() === null && 0 < count($this->taskExecutionRepository->findByTask($task))) {
            return;
        }

        $scheduleTime = $task->getInterval() ? $task->getInterval()->getNextRunDate() : $task->getFirstExecution();
        $execution = $this->taskExecutionRepository->create($task, $scheduleTime);
        $execution->setStatus(TaskStatus::PLANNED);

        $this->eventDispatcher->dispatch(
            Events::TASK_EXECUTION_CREATE,
            new TaskExecutionEvent($task, $execution)
        );

        $this->taskExecutionRepository->save($execution);
    }
protected function scheduleTask(TaskInterface $task)
    {
        if (null !== ($execution = $this->taskExecutionRepository->findPending($task))) {
            return;
        }

        if ($task->getInterval() === null && 0 < count($this->taskExecutionRepository->findByTask($task))) {
            return;
        }

        $scheduleTime = $task->getInterval() ? $task->getInterval()->getNextRunDate() : $task->getFirstExecution();
        $execution = $this->taskExecutionRepository->create($task, $scheduleTime);
        $execution->setStatus(TaskStatus::PLANNED);

        $this->eventDispatcher->dispatch(
            Events::TASK_EXECUTION_CREATE,
            new TaskExecutionEvent($task, $execution)
        );

        $this->taskExecutionRepository->save($execution);
    }
protected function scheduleTask ( TaskInterface $ task ) { if ( null !== ( $ execution = $ this -> taskExecutionRepository -> findPending ( $ task ) ) ) { return ; } if ( $ task -> getInterval ( ) === null && 0 < count ( $ this -> taskExecutionRepository -> findByTask ( $ task ) ) ) { return ; } $ scheduleTime = $ task -> getInterval ( ) ? $ task -> getInterval ( ) -> getNextRunDate ( ) : $ task -> getFirstExecution ( ) ; $ execution = $ this -> taskExecutionRepository -> create ( $ task , $ scheduleTime ) ; $ execution -> setStatus ( TaskStatus :: PLANNED ) ; $ this -> eventDispatcher -> dispatch ( Events :: TASK_EXECUTION_CREATE , new TaskExecutionEvent ( $ task , $ execution ) ) ; $ this -> taskExecutionRepository -> save ( $ execution ) ; }
Schedule execution for given task.

@param TaskInterface $task
Schedule execution for given task .