dev/src/ReleaseBuilder/ReleaseBuilder.php
public function handleChange(OutputInterface $output, array $commitRelease, $level = null)
    {
        $choices = array_keys($commitRelease);

        if (count($choices) > 1) {
            $options = array_merge([
                'All Components'
            ], $choices, [
                'Go Back'
            ]);

            // By default, all components are batch modified in this method.
            $q = $this->choice('Choose a component to modify.', $options, $options[0]);
            $component = $this->removeDefaultFromChoice($this->askQuestion($q));

            if ($component === 'Go Back') {
                return $commitRelease;
            }

            if ($component === 'All Components') {
                $component = null;
            }
        } else {
            $component = $choices[0];
        }

        if ($level === null) {
            if ($component) {
                $componentOverview = sprintf(
                    '<info>google/%s</info> [<info>%s</info>]:',
                    $component,
                    $this->levels[$commitRelease[$component]['level']]
                );

                $currentMessage = $commitRelease[$component]['message'];
            } else {
                $componentOverview = sprintf(
                    'Modifying <info>%s</info> components.',
                    count($commitRelease)
                );

                $currentMessage = current($commitRelease)['message'];
            }

            $key = 'message';
            $value = $this->ask(sprintf(
                '%s Enter a release note message. Do not enter the Pull Request reference number.'.
                PHP_EOL .'  - Message: <info>%s</info>',
                $componentOverview,
                $currentMessage
            ), $currentMessage);

            $value .= ' (#'. current($commitRelease)['ref'] .')';
        } elseif (array_key_exists($level, $this->levels)) {
            $key = 'level';
            $value = $level;
        } else {
            throw new \Exception('Something went really wrong.');
        }

        if ($component) {
            $commitRelease[$component][$key] = $value;
        } else {
            foreach ($commitRelease as &$commitComponent) {
                $commitComponent[$key] = $value;
            }

        }

        return $commitRelease;
    }
public function handleChange(OutputInterface $output, array $commitRelease, $level = null)
    {
        $choices = array_keys($commitRelease);

        if (count($choices) > 1) {
            $options = array_merge([
                'All Components'
            ], $choices, [
                'Go Back'
            ]);

            // By default, all components are batch modified in this method.
            $q = $this->choice('Choose a component to modify.', $options, $options[0]);
            $component = $this->removeDefaultFromChoice($this->askQuestion($q));

            if ($component === 'Go Back') {
                return $commitRelease;
            }

            if ($component === 'All Components') {
                $component = null;
            }
        } else {
            $component = $choices[0];
        }

        if ($level === null) {
            if ($component) {
                $componentOverview = sprintf(
                    '<info>google/%s</info> [<info>%s</info>]:',
                    $component,
                    $this->levels[$commitRelease[$component]['level']]
                );

                $currentMessage = $commitRelease[$component]['message'];
            } else {
                $componentOverview = sprintf(
                    'Modifying <info>%s</info> components.',
                    count($commitRelease)
                );

                $currentMessage = current($commitRelease)['message'];
            }

            $key = 'message';
            $value = $this->ask(sprintf(
                '%s Enter a release note message. Do not enter the Pull Request reference number.'.
                PHP_EOL .'  - Message: <info>%s</info>',
                $componentOverview,
                $currentMessage
            ), $currentMessage);

            $value .= ' (#'. current($commitRelease)['ref'] .')';
        } elseif (array_key_exists($level, $this->levels)) {
            $key = 'level';
            $value = $level;
        } else {
            throw new \Exception('Something went really wrong.');
        }

        if ($component) {
            $commitRelease[$component][$key] = $value;
        } else {
            foreach ($commitRelease as &$commitComponent) {
                $commitComponent[$key] = $value;
            }

        }

        return $commitRelease;
    }
public function handleChange ( OutputInterface $ output , array $ commitRelease , $ level = null ) { $ choices = array_keys ( $ commitRelease ) ; if ( count ( $ choices ) > 1 ) { $ options = array_merge ( [ 'All Components' ] , $ choices , [ 'Go Back' ] ) ; // By default, all components are batch modified in this method. $ q = $ this -> choice ( 'Choose a component to modify.' , $ options , $ options [ 0 ] ) ; $ component = $ this -> removeDefaultFromChoice ( $ this -> askQuestion ( $ q ) ) ; if ( $ component === 'Go Back' ) { return $ commitRelease ; } if ( $ component === 'All Components' ) { $ component = null ; } } else { $ component = $ choices [ 0 ] ; } if ( $ level === null ) { if ( $ component ) { $ componentOverview = sprintf ( '<info>google/%s</info> [<info>%s</info>]:' , $ component , $ this -> levels [ $ commitRelease [ $ component ] [ 'level' ] ] ) ; $ currentMessage = $ commitRelease [ $ component ] [ 'message' ] ; } else { $ componentOverview = sprintf ( 'Modifying <info>%s</info> components.' , count ( $ commitRelease ) ) ; $ currentMessage = current ( $ commitRelease ) [ 'message' ] ; } $ key = 'message' ; $ value = $ this -> ask ( sprintf ( '%s Enter a release note message. Do not enter the Pull Request reference number.' . PHP_EOL . '  - Message: <info>%s</info>' , $ componentOverview , $ currentMessage ) , $ currentMessage ) ; $ value .= ' (#' . current ( $ commitRelease ) [ 'ref' ] . ')' ; } elseif ( array_key_exists ( $ level , $ this -> levels ) ) { $ key = 'level' ; $ value = $ level ; } else { throw new \ Exception ( 'Something went really wrong.' ) ; } if ( $ component ) { $ commitRelease [ $ component ] [ $ key ] = $ value ; } else { foreach ( $ commitRelease as & $ commitComponent ) { $ commitComponent [ $ key ] = $ value ; } } return $ commitRelease ; }
An interactive flow for modifying release data.

@param OutputInterface $output
@param array $commitRelease Structured data about components modified by
the current commit.
@param int|null $level The level to change to. If null, assume change release message.
An interactive flow for modifying release data .