src/Common/Console/Command/Install.php
private function setVars(&$vars)
    {
        foreach ($vars as &$v) {

            if (is_array($v)) {

                $question = 'What should "' . $v['label'] . '" be set to?';

                if (!empty($v['options'])) {

                    $question .= ' (' . implode('|', $v['options']) . ')';

                    //  The field has options, ensure the option selected is valid
                    do {

                        $v['value'] = $this->ask($question, $v['value']);
                        if (isset($v['callback']) && is_callable($v['callback'])) {
                            $v['value'] = call_user_func($v['callback'], $v['value']);
                        }

                        $bIsValidOption = in_array($v['value'], $v['options']);
                        $question       = '<error>Selection must be one of ' . implode(', ', $v['options']) . '</error>';

                    } while (!$bIsValidOption);


                } elseif (isset($v['validate']) && is_callable($v['validate'])) {

                    //  Validator, keep asking until validator passes
                    do {

                        $v['value'] = $this->ask($question, $v['value']);
                        if (isset($v['callback']) && is_callable($v['callback'])) {
                            $v['value'] = call_user_func($v['callback'], $v['value']);
                        }

                        $question = '<error>Sorry, that is not a valid selection.</error>';

                    } while (!call_user_func($v['validate'], $v['value']));

                } else {
                    //  No validator, just ask and accept what's given
                    $v['value'] = $this->ask($question, $v['value']);
                    if (isset($v['callback']) && is_callable($v['callback'])) {
                        $v['value'] = call_user_func($v['callback'], $v['value']);
                    }
                }
            }
        }
    }
private function setVars(&$vars)
    {
        foreach ($vars as &$v) {

            if (is_array($v)) {

                $question = 'What should "' . $v['label'] . '" be set to?';

                if (!empty($v['options'])) {

                    $question .= ' (' . implode('|', $v['options']) . ')';

                    //  The field has options, ensure the option selected is valid
                    do {

                        $v['value'] = $this->ask($question, $v['value']);
                        if (isset($v['callback']) && is_callable($v['callback'])) {
                            $v['value'] = call_user_func($v['callback'], $v['value']);
                        }

                        $bIsValidOption = in_array($v['value'], $v['options']);
                        $question       = '<error>Selection must be one of ' . implode(', ', $v['options']) . '</error>';

                    } while (!$bIsValidOption);


                } elseif (isset($v['validate']) && is_callable($v['validate'])) {

                    //  Validator, keep asking until validator passes
                    do {

                        $v['value'] = $this->ask($question, $v['value']);
                        if (isset($v['callback']) && is_callable($v['callback'])) {
                            $v['value'] = call_user_func($v['callback'], $v['value']);
                        }

                        $question = '<error>Sorry, that is not a valid selection.</error>';

                    } while (!call_user_func($v['validate'], $v['value']));

                } else {
                    //  No validator, just ask and accept what's given
                    $v['value'] = $this->ask($question, $v['value']);
                    if (isset($v['callback']) && is_callable($v['callback'])) {
                        $v['value'] = call_user_func($v['callback'], $v['value']);
                    }
                }
            }
        }
    }
private function setVars ( & $ vars ) { foreach ( $ vars as & $ v ) { if ( is_array ( $ v ) ) { $ question = 'What should "' . $ v [ 'label' ] . '" be set to?' ; if ( ! empty ( $ v [ 'options' ] ) ) { $ question .= ' (' . implode ( '|' , $ v [ 'options' ] ) . ')' ; //  The field has options, ensure the option selected is valid do { $ v [ 'value' ] = $ this -> ask ( $ question , $ v [ 'value' ] ) ; if ( isset ( $ v [ 'callback' ] ) && is_callable ( $ v [ 'callback' ] ) ) { $ v [ 'value' ] = call_user_func ( $ v [ 'callback' ] , $ v [ 'value' ] ) ; } $ bIsValidOption = in_array ( $ v [ 'value' ] , $ v [ 'options' ] ) ; $ question = '<error>Selection must be one of ' . implode ( ', ' , $ v [ 'options' ] ) . '</error>' ; } while ( ! $ bIsValidOption ) ; } elseif ( isset ( $ v [ 'validate' ] ) && is_callable ( $ v [ 'validate' ] ) ) { //  Validator, keep asking until validator passes do { $ v [ 'value' ] = $ this -> ask ( $ question , $ v [ 'value' ] ) ; if ( isset ( $ v [ 'callback' ] ) && is_callable ( $ v [ 'callback' ] ) ) { $ v [ 'value' ] = call_user_func ( $ v [ 'callback' ] , $ v [ 'value' ] ) ; } $ question = '<error>Sorry, that is not a valid selection.</error>' ; } while ( ! call_user_func ( $ v [ 'validate' ] , $ v [ 'value' ] ) ) ; } else { //  No validator, just ask and accept what's given $ v [ 'value' ] = $ this -> ask ( $ question , $ v [ 'value' ] ) ; if ( isset ( $ v [ 'callback' ] ) && is_callable ( $ v [ 'callback' ] ) ) { $ v [ 'value' ] = call_user_func ( $ v [ 'callback' ] , $ v [ 'value' ] ) ; } } } } }
Requests the user to confirm all the variables

@param array &$vars An array of the variables to set
Requests the user to confirm all the variables