Set up options on single field depending on form options

@param string $name
@param $options
480186
protected function setupFieldOptions($name, &$options)
    {
        if (!$this->getName()) {
            return;
        }

        $options['real_name'] = $name;

        if (!isset($options['label'])) {
            $options['label'] = $this->formHelper->formatLabel($name);
        }
    }
497947
protected function addOption(string $name, string $value): void
    {
        $this->options[$name] = $value;
    }
1047118
public function setOption($name, $value = null)
    {
        if (is_array($name)) {
            $this->_option = $name;
        } elseif (is_null($value)) {
            unset($this->_option[$name]);
        } else {
            $this->_option[$name] = $value;
        }
    }
1126275
public function setOption($name, $shortcut = null, $inputRequired = false, $description = 'option does what?')
    {
        $inputRequired ? $inputRequired = InputOption::VALUE_REQUIRED :
            $inputRequired = InputOption::VALUE_OPTIONAL;

        $this->addOption($name, $shortcut, $inputRequired, $description);
    }
1014655
protected function makeField($name, $type = 'text', array $options = [])
    {
        $this->setupFieldOptions($name, $options);

        $fieldName = $this->getFieldName($name);

        $fieldType = $this->getFieldType($type);

        $field = new $fieldType($fieldName, $type, $this, $options);

        $this->eventDispatcher->dispatch(new AfterFieldCreation($this, $field));

        return $field;
    }
1114310
protected function _addMenu($name, $options)
    {
        $requstParams = $this->Controller->request->params;
        if (key_exists('prefix', $requstParams) && $requstParams['prefix'] == 'admin') {
            $this->Controller->Menu->add($options['alias'], [
                'url' => [
                    'prefix' => 'admin',
                    'plugin' => 'PostTypes',
                    'controller' => 'PostTypes',
                    'action' => 'index',
                    'type' => lcfirst($name),
                ]
            ]);
        }
    }
234756
public function setOption($name, $value)
    {
        $this->validate($name, $value);
        $this->options[$name] = $value;

        return $this;
    }
400024
protected function _addIdAttribute($name, array &$options) {
        $names = array(
            $this->getName(),
            $name
        );
        $parent = $this;
        while ($parent = $parent->getParent()) {
            $name = $parent->getName();
            if (!is_null($name)) {
                array_unshift($names, $parent->getName());
            }
        }
        $name = implode('-', $names);
        // if the root form has no name, the id will start with "-"
        $name = ltrim($name, '-');
        $options['id'] = strtolower($name) . '-field';
    }
853587
public function addFormField(string $name): void
    {
        $options = $this->formOptions['fields'][$name];
        $wrapper = $this->createWrapper();
        $label = '';

        if (isset($options['label']['text'])) {
            $label = $this->createLabel($options['label']['text'], $name);

            unset($options['label']['text']);
        }

        $input = HtmlTag::createElement('input')
            ->set('type', $options['input']['type'] ?? 'text')
            ->set('id', $name)
            ->set('name', $name);

        $caption = '';

        if (isset($options['caption']['text'])) {
            $input->set('aria-describedby', $name . '_caption');
            $caption = $this->createCaption($options['caption']['text'], $name);

            unset($options['caption']['text']);
        }

        $elements = [
            'wrapper' => $wrapper,
            'label'   => $label,
            'input'   => $input,
            'caption' => $caption
        ];

        foreach ($elements as $name => $element) {
            $$name = $this->assignOptionsToElement($options, $name, $element);
        }

        if (in_array($options['input']['type'] ?? 'text', ['checkbox', 'radio', 'file'])) {
            $wrapper->addElement($input);
            $wrapper->addElement($label);
        } else {
            $wrapper->addElement($label);
            $wrapper->addElement($input);
        }

        $wrapper->addElement($caption);

        echo $wrapper;
    }
790649
public function textarea(string $name, array $options = []): FieldTypeInterface
    {
        return (new TextareaType($name))
            ->setLocale($this->app->getLocale())
            ->setViewFactory($this->viewFactory)
            ->setOptions($options);
    }
1060779
public function offsetSet($name, $option)
    {
        $name = $option->getName();

        $this->options[$name] = $option;
    }
242141
public function task($name, array $options = [])
    {
        $this->taskProcessor->setOutput($this);
        $this->taskProcessor->execute($name, $options);
    }
106834
public function optionName($name)
    {
        if (empty($this->optionPath)) {
            $this->optionPath = PATH_RESOURCES . 'themes' . DIRECTORY_SEPARATOR;
        }

        $this->optionName = $name;
    }
332147
public function setName($name) {
        if ($name !== null && ! $this->argumentsParser->isOptionName($name)) {
            throw new InvalidOptionNameException(s(
                'A option name must have this format: "--option", got: "%s"', $name
            ));
        }

        $this->name = $name;

        return $this;
    }
50956
public function setOptions(array $options)
    {
        if ($this->frozen) {
            throw new Exception('The options for the field "'.$this->name.'"');
        }
        $this->options = $options;
        $this->frozen = true;
    }
791738
protected function makeField($name, $type = 'text', array $options = [])
    {
        $this->setupFieldOptions($name, $options);

        $fieldName = $this->getFieldName($name);

        $fieldType = $this->getFieldType($type);

        return new $fieldType($fieldName, $type, $this, $options);
    }
49545
public function setViewElement(string $name, array $data = [], array $options = []): void
    {
        $this->viewElement = [$name, $data, $options];
    }