Get the field as a Console question.

@return Question
357630
public function getAsQuestion()
    {
        $question = new Question($this->getQuestionText(), $this->default);
        $question->setMaxAttempts($this->maxAttempts);
        $question->setValidator(function ($value) {
            if ($this->isEmpty($value) && $this->isRequired()) {
                throw new MissingValueException("'{$this->name}' is required");
            }
            $this->validate($value);

            return $value;
        });
        $question->setAutocompleterValues($this->autoCompleterValues);

        return $question;
    }
68673
public function getValue()
    {
        return isset($this->field) ? $this->app->ui_persistence->typecastSaveField($this->field, $this->field->get()) : (isset($this->content) ? $this->content : '');
    }
198861
public function ask(InputInterface $input, OutputInterface $output, Question $question)
    {
        if ($output instanceof ConsoleOutputInterface) {
            $output = $output->getErrorOutput();
        }

        if (!$input->isInteractive()) {
            $default = $question->getDefault();

            if (null === $default) {
                return $default;
            }

            if ($validator = $question->getValidator()) {
                return \call_user_func($question->getValidator(), $default);
            } elseif ($question instanceof ChoiceQuestion) {
                $choices = $question->getChoices();

                if (!$question->isMultiselect()) {
                    return isset($choices[$default]) ? $choices[$default] : $default;
                }

                $default = explode(',', $default);
                foreach ($default as $k => $v) {
                    $v = trim($v);
                    $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
                }
            }

            return $default;
        }

        if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) {
            $this->inputStream = $stream;
        }

        if (!$question->getValidator()) {
            return $this->doAsk($output, $question);
        }

        $interviewer = function () use ($output, $question) {
            return $this->doAsk($output, $question);
        };

        return $this->validateAttempts($interviewer, $output, $question);
    }
1334902
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Field Objects:
        
        $fields->fieldByName('Root.Options.TitleOptions')->push(
            CheckboxField::create(
                'UseLevelTitle',
                $this->fieldLabel('UseLevelTitle')
            )
        );
        
        // Create Options Fields:
        
        $fields->addFieldToTab(
            'Root.Options',
            FieldSection::create(
                'NavigationOptions',
                $this->fieldLabel('NavigationOptions'),
                [
                    DropdownField::create(
                        'SortBy',
                        $this->fieldLabel('SortBy'),
                        $this->getSortByOptions()
                    ),
                    CheckboxField::create(
                        'ShowCount',
                        $this->fieldLabel('ShowCount')
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
757974
public function getFieldBody()
    {
        if (!$this->getCachedValue()) {
            $this->setCachedValue(
                $this->encodeWords($this, $this->value)
                );
        }

        return $this->getCachedValue();
    }
824209
public function getConsole()
    {
        if (!($this->console instanceof AdapterInterface)) {
            $this->console = Console::getInstance();
        }

        return $this->console;
    }
843119
public function field()
    {
        $field = $this->getConfig('field');
        if (!$this->getConfig('aliasField')) {
            return $field;
        }

        $repository = $this->manager()->getRepository();
        if (!method_exists($repository, 'aliasField')) {
            return $field;
        }

        if (is_string($field)) {
            return $repository->aliasField($field);
        }

        $return = [];
        foreach ($field as $fld) {
            $return[] = $repository->aliasField($fld);
        }

        return $return;
    }
793109
public function getValue()
    {
        if ($option = $this->Options()->byID($this->getField('Value'))) {
            return $option->Title;
        }

        return null;
    }
996677
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                TextField::create(
                    'DeveloperName',
                    $this->fieldLabel('DeveloperName')
                ),
                PageDropdownField::create(
                    'DeveloperPageID',
                    $this->fieldLabel('DeveloperPageID')
                ),
                TextField::create(
                    'DeveloperURL',
                    $this->fieldLabel('DeveloperURL')
                )
            ]
        );
        
        // Create Options Fields:
        
        $fields->addFieldsToTab(
            'Root.Options',
            [
                FieldSection::create(
                    'DeveloperOptions',
                    $this->fieldLabel('DeveloperOptions'),
                    [
                        TextField::create(
                            'DeveloperText',
                            $this->fieldLabel('DeveloperText')
                        ),
                        CheckboxField::create(
                            'OpenLinkInNewTab',
                            $this->fieldLabel('OpenLinkInNewTab')
                        ),
                        CheckboxField::create(
                            'LinkDisabled',
                            $this->fieldLabel('LinkDisabled')
                        )
                    ]
                )
            ]
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
529617
public function getExpr()
    {
        $q = $this->owner->_dsql();

        return $q->bt($this->relation ? $this->relation->short_name : $q->main_table).'.'.
            $q->bt($this->actual_field ?: $this->short_name);
    }
884890
public function getCMSFields()
    {
        // Create Field Tab Set:
        
        $fields = FieldList::create(TabSet::create('Root'));
        
        // Create Main Fields:
        
        $fields->addFieldsToTab(
            'Root.Main',
            [
                TextField::create(
                    'Title',
                    $this->fieldLabel('Title')
                )
            ]
        );
        
        // Extend Field Objects:
        
        $this->extend('updateCMSFields', $fields);
        
        // Answer Field Objects:
        
        return $fields;
    }
23012
public function get_course() {
        global $DB;
        if (!$this->courseid) {
            return null;
        }
        if ($this->course === false) {
            $this->course = get_course($this->courseid);
            $options = $this->get_format_options();
            $dbcoursecolumns = null;
            foreach ($options as $optionname => $optionvalue) {
                if (isset($this->course->$optionname)) {
                    // Course format options must not have the same names as existing columns in db table "course".
                    if (!isset($dbcoursecolumns)) {
                        $dbcoursecolumns = $DB->get_columns('course');
                    }
                    if (isset($dbcoursecolumns[$optionname])) {
                        debugging('The option name '.$optionname.' in course format '.$this->format.
                            ' is invalid because the field with the same name exists in {course} table',
                            DEBUG_DEVELOPER);
                        continue;
                    }
                }
                $this->course->$optionname = $optionvalue;
            }
        }
        return $this->course;
    }
630314
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Style Fields:
        
        $fields->addFieldToTab(
            'Root.Style',
            FieldSection::create(
                'ColumnStyle',
                $this->fieldLabel('Column'),
                [
                    ViewportsField::create(
                        'ColumnSpan',
                        $this->fieldLabel('Span'),
                        $this->getColumnSpanOptions()
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
1059061
public function getCMSFields()
    {
        // Obtain Field Objects (from parent):
        
        $fields = parent::getCMSFields();
        
        // Create Options Fields:
        
        $fields->addFieldToTab(
            'Root.Options',
            FieldSection::create(
                'NavigationOptions',
                $this->fieldLabel('NavigationOptions'),
                [
                    CheckboxField::create(
                        'HideTopLevel',
                        $this->fieldLabel('HideTopLevel')
                    )
                ]
            )
        );
        
        // Answer Field Objects:
        
        return $fields;
    }
360787
public function field()
    {
        $field = $this->getAttribute('field');

        if ($field || false === $field) {
            return $field;
        }

        return $this->getAttribute('relation');
    }
1259301
protected function getSimpleQuestion()
    {
        if (!$this->getHelperSet()->has('simple_question')) {
            $this->getHelperSet()->set(new SimpleQuestionHelper());
        }

        return $this->getHelperSet()->get('simple_question');
    }
23187
public static function console()
    {
        self::init();

        /*
         * Get the command line parameters.
         */
        $argv = $_SERVER['argv'];
        array_shift($argv); // strip the application name ("console")

        /*
         * Dispatch the command line request.
         */
        /** @var \Core\Services\Contracts\Command|false $command */
        $command = DI::getInstance()->get('command-factory')->command($argv);
        $status = $command->run();

        return $status;
    }