src/Knp/Minibus/Line/Line.php
public function lead(MinibusInterface $minibus)
    {
        // start the lead.
        $startEvent = $this->eventFactory->createStart($minibus);
        $this->dispatcher->dispatch(LineEvents::START, $startEvent);

        $minibus = $startEvent->getMinibus();

        // launch the stations
        foreach ($this->stations as $station) {
            $configuration = $this->stations[$station];
            // pre validate entering passengers
            $gateOpenEvent = $this->eventFactory->createGate($minibus, $station);
            $this->dispatcher->dispatch(LineEvents::GATE_OPEN, $gateOpenEvent);

            // parse the configuration if needed
            if ($station instanceof Configurable) {
                $configuration = $this->configurationProcessor->processConfiguration(
                    $station->getConfiguration(),
                    [$configuration]
                );
            }

            // launch the station
            $station->handle($minibus, $configuration);

            // post validate leaving passengers
            $gateCloseEvent = $this->eventFactory->createGate($minibus, $station);
            $this->dispatcher->dispatch(LineEvents::GATE_CLOSE, $gateCloseEvent);
        }

        // process terminus configuration if needed
        if (null !== $this->terminus and $this->terminus instanceof Configurable) {
            $this->configuration = $this->configurationProcessor->processConfiguration(
                $this->terminus->getConfiguration(),
                [$this->configuration]
            );
        }

        // terminate the line
        $terminusEvent = $this->eventFactory->createTerminus(
            $minibus,
            $this->terminus,
            $this->configuration
        );
        $this->dispatcher->dispatch(LineEvents::TERMINUS, $terminusEvent);

        $terminus      = $terminusEvent->getTerminus();
        $configuration = $terminusEvent->getConfiguration();

        return null === $terminus ? $minibus : $terminus->terminate($minibus, $configuration);
    }
public function lead(MinibusInterface $minibus)
    {
        // start the lead.
        $startEvent = $this->eventFactory->createStart($minibus);
        $this->dispatcher->dispatch(LineEvents::START, $startEvent);

        $minibus = $startEvent->getMinibus();

        // launch the stations
        foreach ($this->stations as $station) {
            $configuration = $this->stations[$station];
            // pre validate entering passengers
            $gateOpenEvent = $this->eventFactory->createGate($minibus, $station);
            $this->dispatcher->dispatch(LineEvents::GATE_OPEN, $gateOpenEvent);

            // parse the configuration if needed
            if ($station instanceof Configurable) {
                $configuration = $this->configurationProcessor->processConfiguration(
                    $station->getConfiguration(),
                    [$configuration]
                );
            }

            // launch the station
            $station->handle($minibus, $configuration);

            // post validate leaving passengers
            $gateCloseEvent = $this->eventFactory->createGate($minibus, $station);
            $this->dispatcher->dispatch(LineEvents::GATE_CLOSE, $gateCloseEvent);
        }

        // process terminus configuration if needed
        if (null !== $this->terminus and $this->terminus instanceof Configurable) {
            $this->configuration = $this->configurationProcessor->processConfiguration(
                $this->terminus->getConfiguration(),
                [$this->configuration]
            );
        }

        // terminate the line
        $terminusEvent = $this->eventFactory->createTerminus(
            $minibus,
            $this->terminus,
            $this->configuration
        );
        $this->dispatcher->dispatch(LineEvents::TERMINUS, $terminusEvent);

        $terminus      = $terminusEvent->getTerminus();
        $configuration = $terminusEvent->getConfiguration();

        return null === $terminus ? $minibus : $terminus->terminate($minibus, $configuration);
    }
public function lead ( MinibusInterface $ minibus ) { // start the lead. $ startEvent = $ this -> eventFactory -> createStart ( $ minibus ) ; $ this -> dispatcher -> dispatch ( LineEvents :: START , $ startEvent ) ; $ minibus = $ startEvent -> getMinibus ( ) ; // launch the stations foreach ( $ this -> stations as $ station ) { $ configuration = $ this -> stations [ $ station ] ; // pre validate entering passengers $ gateOpenEvent = $ this -> eventFactory -> createGate ( $ minibus , $ station ) ; $ this -> dispatcher -> dispatch ( LineEvents :: GATE_OPEN , $ gateOpenEvent ) ; // parse the configuration if needed if ( $ station instanceof Configurable ) { $ configuration = $ this -> configurationProcessor -> processConfiguration ( $ station -> getConfiguration ( ) , [ $ configuration ] ) ; } // launch the station $ station -> handle ( $ minibus , $ configuration ) ; // post validate leaving passengers $ gateCloseEvent = $ this -> eventFactory -> createGate ( $ minibus , $ station ) ; $ this -> dispatcher -> dispatch ( LineEvents :: GATE_CLOSE , $ gateCloseEvent ) ; } // process terminus configuration if needed if ( null !== $ this -> terminus and $ this -> terminus instanceof Configurable ) { $ this -> configuration = $ this -> configurationProcessor -> processConfiguration ( $ this -> terminus -> getConfiguration ( ) , [ $ this -> configuration ] ) ; } // terminate the line $ terminusEvent = $ this -> eventFactory -> createTerminus ( $ minibus , $ this -> terminus , $ this -> configuration ) ; $ this -> dispatcher -> dispatch ( LineEvents :: TERMINUS , $ terminusEvent ) ; $ terminus = $ terminusEvent -> getTerminus ( ) ; $ configuration = $ terminusEvent -> getConfiguration ( ) ; return null === $ terminus ? $ minibus : $ terminus -> terminate ( $ minibus , $ configuration ) ; }
Lead the minibus thrie all the stations. If you have defined a Terminus
then the terminus resolved data should be return else the minibus is return.
This method also dispatch events

@see LineEvents

@param Minibus $minibus

@return Minibus|mixed
Lead the minibus thrie all the stations . If you have defined a Terminus then the terminus resolved data should be return else the minibus is return . This method also dispatch events