public function addQuestion(Item $question)
    {
        $stepQuestions = $this->stepQuestions->toArray();
        foreach ($stepQuestions as $stepQuestion) {
            /** @var StepItem $stepQuestion */
            if ($stepQuestion->getQuestion() === $question) {
                return; // The question is already linked to the Step
            }
        }

        // Create a new StepItem to attach the question to the step
        $stepQuestion = new StepItem();
        $stepQuestion->setOrder($this->stepQuestions->count());
        $stepQuestion->setStep($this);
        $stepQuestion->setQuestion($question);

        return $stepQuestion;
    }
public function addQuestion(Item $question)
    {
        $stepQuestions = $this->stepQuestions->toArray();
        foreach ($stepQuestions as $stepQuestion) {
            /** @var StepItem $stepQuestion */
            if ($stepQuestion->getQuestion() === $question) {
                return; // The question is already linked to the Step
            }
        }

        // Create a new StepItem to attach the question to the step
        $stepQuestion = new StepItem();
        $stepQuestion->setOrder($this->stepQuestions->count());
        $stepQuestion->setStep($this);
        $stepQuestion->setQuestion($question);

        return $stepQuestion;
    }
public function addQuestion ( Item $ question ) { $ stepQuestions = $ this -> stepQuestions -> toArray ( ) ; foreach ( $ stepQuestions as $ stepQuestion ) { /** @var StepItem $stepQuestion */ if ( $ stepQuestion -> getQuestion ( ) === $ question ) { return ; // The question is already linked to the Step } } // Create a new StepItem to attach the question to the step $ stepQuestion = new StepItem ( ) ; $ stepQuestion -> setOrder ( $ this -> stepQuestions -> count ( ) ) ; $ stepQuestion -> setStep ( $ this ) ; $ stepQuestion -> setQuestion ( $ question ) ; return $ stepQuestion ; }
Shortcut to add Items to Step.
Avoids the need to manually initialize a StepItem object to hold the relation.

@param Item $question - the question to add to the step

@return StepItem
Shortcut to add Items to Step . Avoids the need to manually initialize a StepItem object to hold the relation .