Get options to apply on field value

@param FieldInterface $field

@return array
967307
public function getFormFieldValueOptions(FieldInterface $field)
    {
        $formFieldOptions = [];
        $formFieldOptions['choices'] = array_flip($this->getFieldOptionsArray($field));
        $formFieldOptions['expanded'] = $this->isExpanded;
        $formFieldOptions['multiple'] = $this->getIsMultipleChoice($field);

        return $formFieldOptions;
    }
310919
protected function validateOptions(array $options, FieldTypeInterface $field)
    {
        $parsed = [];

        foreach ($options as $key => $value) {
            if (! in_array($key, $field->getAllowedOptions(), true)) {
                throw new \DomainException('The "'.$key.'" option is not allowed on the provided field.');
            }

            $parsed[$key] = $value;
        }

        return $parsed;
    }
166328
public function getAvailableOptions(
        ProductInterface $product,
        AttributeInterface $attribute
    ) {
        $availableOptions = new ArrayCollection();

        foreach ($product->getVariants() as $variant) {

            /**
             * @var VariantInterface $variant
             */
            if (!$variant->isEnabled() || $variant->getStock() <= 0) {
                continue;
            }

            foreach ($variant->getOptions() as $option) {
                /**
                 * @var ValueInterface $option
                 */
                if ($option->getAttribute() == $attribute &&
                    !$availableOptions->contains($option)
                ) {
                    $availableOptions->add($option);
                }
            }
        }

        return $availableOptions;
    }
264541
public function clearOptions(FieldInterface $field)
    {
        $options = $field->getOptions();

        $optionNames = $this->getFieldOptionNames();
        foreach ($options as $key => $value) {
            if (in_array($key, $optionNames)) {
                continue;
            }
            unset($options[$key]);
        }

        $field->setOptions($options);
    }
870957
protected function assignValue(FieldInterface $field)
    {
        $value = $this->accessor->getPropertyValue($this->instance, $field->name());

        if ($value === null && $field->attribute('autoincrement')) {
            return;
        }

        if ($value === null) {
            $this->getValueFromReferencedEntity($field);
        }

        $this->builder->setValue(
            $this->connection->quoteIdentifier($field->mappedName()),
            $this->builder->createNamedParameter($value, $field->type())
        );
    }
536685
public function getFormFieldValueOptions(FieldInterface $field)
    {
        $fieldOptions = $this->getFieldOptions($field);

        $formFieldOptions = parent::getFormFieldValueOptions($field);
        if (isset($fieldOptions['nbRows'])) {
            $formFieldOptions['attr'] = ['rows' => $fieldOptions['nbRows']];
        }

        return $formFieldOptions;
    }
705967
public function getSettersGetters($fields, $isInterface = false)
    {
        $settersGetters = null;
        foreach ($fields as $field) {
            $getter = 'get'.studly_case($field);
            $setter = 'set'.studly_case($field);
            $settersGetters .= $isInterface ? "\n
    /**
     * Get $field.
     *
     * @return mixed
     */
    public function $getter();
    
    /**
     * Set $field.
     *
     * @param $$field
     *
     * @return mixed
     */
    public function $setter($$field);"

                : "\n
    /**
     * {@inheritdoc}
     */
    public function $getter()
    {
        return \$this->$field;
    }
    
    /**
     * {@inheritdoc}
     */
    public function $setter($$field)
    {
        \$this->$field = $$field;
        return \$this;
    }";
        }

        return $settersGetters;
    }
1347110
function GetOptions($field) {
		$this->LoadSchema();
		if (
			isset($this->schema[$field]) && // A valid field
			isset($this->schema[$field]['options']) // Valid options
		)
			return $this->schema[$field]['options'];
	}
1168432
protected function _getFieldsFor(FieldListAwareInterface $object)
    {
        if (is_null($object->getFields())) {
            return false;
        }
        if (is_string($object->getFields())) {
            return $object->getFields();
        }
        $alias = (is_null($object->getAlias())) ?
            $object->getTable() : $object->getAlias();
        $fields = [];
        foreach ($object->getFields() as $field) {
            $fields[] = "{$alias}.{$field}";
        }

        return implode(', ', $fields);
    }
174406
public function map(Field $field)
    {
        $values = array();

        foreach ((array)$field->value as $value) {
            $values[] = (bool)$value;
        }

        return $values;
    }
1088214
public function getFilterField(AttributeInterface $attribute)
    {
        $field = $attribute->getAttributeCode();

        if ($attribute->usesSource()) {
            $field = $this->getOptionTextFieldName($field);
        }

        return $field;
    }
1121467
protected function getStaticFieldValues(ObjectInterface $version)
    {
        /** @var \Concrete\Core\Page\Collection\Version\Version $version */

        /** @var \Concrete\Core\Page\Page $page */
        $page = Page::getByID($version->getCollectionID());

        yield (int) $page->getCollectionID();
        yield (string) $page->getCollectionPath();
        yield (string) $page->getCollectionName();
        yield (int) $version->getVersionID();
        yield (string) $this->getLocalizedDate($version->getVersionDateApproved());
        yield (string) $version->getVersionComments();
        yield (string) $version->getVersionAuthorUserName();
        yield (string) $version->getVersionApproverUserName();
    }
618642
public static function getPHPFormat(EntityInterface $field)
    {
        $settings = $field->metadata->settings;
        $format = empty($settings['format']) ? 'yy-mm-dd' : $settings['format'];
        if ($settings['timepicker']) {
            $format .= ' ';
            if (empty($settings['time_format'])) {
                $format .= 'H:mm';
                $format .= empty($settings['time_seconds']) ?: ':ss';
            } else {
                $format .= $settings['time_format'];
            }
        }

        return static::normalizeFormat($format);
    }
702174
protected function getFieldClientOptions($field)
    {
        $attribute = Html::getAttributeName($field->attribute);
        if (!in_array($attribute, $field->model->activeAttributes(), true)) {
            return [];
        }

        $clientValidation = $field->isClientValidationEnabled();
        $ajaxValidation = $field->isAjaxValidationEnabled();

        if ($clientValidation) {
            $validators = [];
            foreach ($field->model->getActiveValidators($attribute) as $validator) {
                /* @var $validator \yii\validators\Validator */
                if (!$validator->enableClientValidation) {
                    continue;
                }

                $js = $validator->clientValidateAttribute($field->model, $attribute, $field->form->getView());
                if ($js === null || $js === '') {
                    $js = $this->buildClientValidator($validator, $field->model, $attribute, $field->form->getView());
                }

                if ($js !== '') {
                    if ($validator->whenClient !== null) {
                        $js = "if (({$validator->whenClient})(attribute, value)) { $js }";
                    }
                    $validators[] = $js;
                }
            }
        }

        if (!$ajaxValidation && (!$clientValidation || empty($validators))) {
            return [];
        }

        $options = [];

        $inputID = $field->getInputId();
        $options['id'] = Html::getInputId($field->model, $field->attribute);
        $options['name'] = $field->attribute;

        $options['container'] = $field->selectors['container'] ?? ".field-$inputID";
        $options['input'] = $field->selectors['input'] ?? "#$inputID";
        if (isset($field->selectors['error'])) {
            $options['error'] = $field->selectors['error'];
        } elseif (isset($field->errorOptions['class'])) {
            $options['error'] = '.'.implode('.', preg_split('/\s+/', $field->errorOptions['class'], -1, PREG_SPLIT_NO_EMPTY));
        } else {
            $options['error'] = $field->errorOptions['tag'] ?? 'span';
        }

        $options['encodeError'] = !isset($field->errorOptions['encode']) || $field->errorOptions['encode'];
        if ($ajaxValidation) {
            $options['enableAjaxValidation'] = true;
        }
        foreach (['validateOnChange', 'validateOnBlur', 'validateOnType', 'validationDelay'] as $name) {
            $options[$name] = $field->$name ?? $field->form->$name;
        }

        if (!empty($validators)) {
            $options['validate'] = new JsExpression('function (attribute, value, messages, deferred, $form) {'.implode('', $validators).'}');
        }

        if ($field->addAriaAttributes === false) {
            $options['updateAriaInvalid'] = false;
        }

        return $options;
    }
584862
private function getOptions(MethodInterface $method)
    {
        if ($method->getMethod() == $method::GET) {
            return [
                'query' => $method->getAttributes(),
            ];
        }

        return [
            'headers' => [
                'Content-Type' => 'application/json',
            ],
            'body' => json_encode(
                $this->prepareAttributes($method->getAttributes()),
                JSON_FORCE_OBJECT
            )
        ];
    }
269025
public function resolveSelectOptions($field, array $values)
    {
        $options = $this->resolveForSelection($field)
                ->findElements(WebDriverBy::tagName('option'));

        if (empty($options)) {
            return [];
        }

        return array_filter($options, function ($option) use ($values) {
            return in_array($option->getAttribute('value'), $values);
        });
    }
495550
public function serialize(Field $field, array $options = [])
    {
        $serialized = [
            'id' => $field->getUuid(),
            'autoId' => $field->getId(),
            'name' => $field->getName(),
            'label' => $field->getName(),
            'type' => $field->getFieldType(),
            'required' => $field->isRequired(),
            'help' => $field->getHelp(),
            'restrictions' => [
                'isMetadata' => $field->getIsMetadata(),
                'locked' => $field->isLocked(),
                'lockedEditionOnly' => $field->getLockedEditionOnly(),
                'hidden' => $field->isHidden(),
                'order' => $field->getOrder(),
            ],
        ];

        if (count($field->getDetails()) > 0) {
            $serialized['options'] = $field->getDetails();
        }
        if (in_array($field->getType(), [FieldFacet::CHOICE_TYPE, FieldFacet::CASCADE_TYPE])) {
            $serialized['options']['choices'] = array_map(function (FieldFacetChoice $choice) {
                return $this->fieldFacetChoiceSerializer->serialize($choice);
            }, $field->getFieldFacet()->getRootFieldFacetChoices());
        }
        if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
            $serialized = array_merge($serialized, [
                'fieldFacet' => $this->fieldFacetSerializer->serialize($field->getFieldFacet()),
            ]);
        } else {
            $serialized = array_merge($serialized, [
                'fieldFacet' => [
                    'id' => $field->getUuid(),
                ],
            ]);
        }

        return $serialized;
    }