protected function resolve(TaskConfiguration $taskConfiguration): bool
    {
        $state = $taskConfiguration->getState();
        if ($state->isResolved()) {
            return true;
        }

        $state->setStatus(ProcessState::STATUS_PENDING);

        // Resolve parents first
        $allParentsResolved = true;
        foreach ($taskConfiguration->getPreviousTasksConfigurations() as $previousTasksConfiguration) {
            if (!$previousTasksConfiguration->getState()->isResolved()) {
                $isResolved = $this->resolve($previousTasksConfiguration);
                $allParentsResolved = $allParentsResolved && $isResolved;
            }
        }

        if (!$allParentsResolved) {
            throw new \UnexpectedValueException('Cannot resolve all parents');
        }

        $state->setStatus(ProcessState::STATUS_PROCESSING);

        // Start processing only roots that are not in error branch
        if ($taskConfiguration->isRoot()) {
            $this->process($taskConfiguration);
        }

        // Then we can proceed with BlockingTask only if they have been processed normally and where never "proceeded"
        if ($taskConfiguration->getTask() instanceof BlockingTaskInterface
            && $this->hasProcessedBlocking($taskConfiguration)
        ) {
            $this->process($taskConfiguration, self::EXECUTE_PROCEED);
        }

        // This task is now finished, we may flush it to test if there is anything lasting
        $this->flush($taskConfiguration);

        $state->setStatus(ProcessState::STATUS_RESOLVED);

        return $state->isResolved();
    }
protected function resolve(TaskConfiguration $taskConfiguration): bool
    {
        $state = $taskConfiguration->getState();
        if ($state->isResolved()) {
            return true;
        }

        $state->setStatus(ProcessState::STATUS_PENDING);

        // Resolve parents first
        $allParentsResolved = true;
        foreach ($taskConfiguration->getPreviousTasksConfigurations() as $previousTasksConfiguration) {
            if (!$previousTasksConfiguration->getState()->isResolved()) {
                $isResolved = $this->resolve($previousTasksConfiguration);
                $allParentsResolved = $allParentsResolved && $isResolved;
            }
        }

        if (!$allParentsResolved) {
            throw new \UnexpectedValueException('Cannot resolve all parents');
        }

        $state->setStatus(ProcessState::STATUS_PROCESSING);

        // Start processing only roots that are not in error branch
        if ($taskConfiguration->isRoot()) {
            $this->process($taskConfiguration);
        }

        // Then we can proceed with BlockingTask only if they have been processed normally and where never "proceeded"
        if ($taskConfiguration->getTask() instanceof BlockingTaskInterface
            && $this->hasProcessedBlocking($taskConfiguration)
        ) {
            $this->process($taskConfiguration, self::EXECUTE_PROCEED);
        }

        // This task is now finished, we may flush it to test if there is anything lasting
        $this->flush($taskConfiguration);

        $state->setStatus(ProcessState::STATUS_RESOLVED);

        return $state->isResolved();
    }
protected function resolve ( TaskConfiguration $ taskConfiguration ) : bool { $ state = $ taskConfiguration -> getState ( ) ; if ( $ state -> isResolved ( ) ) { return true ; } $ state -> setStatus ( ProcessState :: STATUS_PENDING ) ; // Resolve parents first $ allParentsResolved = true ; foreach ( $ taskConfiguration -> getPreviousTasksConfigurations ( ) as $ previousTasksConfiguration ) { if ( ! $ previousTasksConfiguration -> getState ( ) -> isResolved ( ) ) { $ isResolved = $ this -> resolve ( $ previousTasksConfiguration ) ; $ allParentsResolved = $ allParentsResolved && $ isResolved ; } } if ( ! $ allParentsResolved ) { throw new \ UnexpectedValueException ( 'Cannot resolve all parents' ) ; } $ state -> setStatus ( ProcessState :: STATUS_PROCESSING ) ; // Start processing only roots that are not in error branch if ( $ taskConfiguration -> isRoot ( ) ) { $ this -> process ( $ taskConfiguration ) ; } // Then we can proceed with BlockingTask only if they have been processed normally and where never "proceeded" if ( $ taskConfiguration -> getTask ( ) instanceof BlockingTaskInterface && $ this -> hasProcessedBlocking ( $ taskConfiguration ) ) { $ this -> process ( $ taskConfiguration , self :: EXECUTE_PROCEED ) ; } // This task is now finished, we may flush it to test if there is anything lasting $ this -> flush ( $ taskConfiguration ) ; $ state -> setStatus ( ProcessState :: STATUS_RESOLVED ) ; return $ state -> isResolved ( ) ; }
Resolve a task, by checking if parents are resolved and processing roots and BlockingTasks

@param TaskConfiguration $taskConfiguration

@throws \RuntimeException
@throws \UnexpectedValueException

@return bool
Resolve a task by checking if parents are resolved and processing roots and BlockingTasks