Return select field value options from a ContentType's records.

@param Bag $field

@return array
197763
private function getEntityValues(Bag $field)
    {
        $baseParts = explode('/', $field->get('values'));
        if (count($baseParts) < 2) {
            throw new \InvalidArgumentException(sprintf('The "values" key for a ContentType select must be in the form of ContentType/field_name but "%s" given', $field->get('values')));
        }

        $contentType = $baseParts[0];
        $queryFields = explode(',', $baseParts[1]);
        foreach ($queryFields as $queryField) {
            if ($queryField) {
                continue;
            }
            throw new \InvalidArgumentException(sprintf('The "values" key for a ContentType select must include a single field, or comma separated fields, "%s" given', $field->get('values')));
        }

        $filter = $field->get('filter');
        $filter['order'] = $field->get('sort');
        $filter['limit'] = $field->get('limit', self::DEFAULT_LIMIT);
        /** @var QueryResultset $entities */
        $entities = $this->query->getContent($contentType, $filter);
        if (!$entities) {
            return [];
        }

        $values = [];
        $ctCount = count($entities->getOriginalQueries());
        foreach ($entities as $entity) {
            $id = $entity->get($field->get('keys', 'id'));
            if ($ctCount > 1) {
                $values[(string)$entity->getContenttype() . '/' . $id] = $entity->get($queryFields[0]);
            } else {
                $values[$id] = $entity->get($queryFields[0]);
            }
            if (isset($queryFields[1])) {
                $values[$id] .= ' / ' . $entity->get($queryFields[1]);
            }
        }

        return $values;
    }
908980
public function getJsonFieldType($field)
    {
        return isset($this->options['field_type'][$field]) ? $this->options['field_type'][$field] : null;
    }
1335807
private function getFieldValue($field)
    {
        return isset($this->values[$field]) ? $this->values[$field] : null;
    }
66016
protected function getFieldCriteria(string $field, string $value): array
    {
        // not a searchable field
        if (!array_key_exists($field, $this->searchFields)) {
            return [];
        }

        // unsupported field type for basic search
        $type = $this->searchFields[$field]['type'];
        if (!in_array($type, Options::getBasicSearchFieldTypes())) {
            return [];
        }

        $result = [];
        switch ($type) {
            case 'related':
                $result = $this->getRelatedFieldValue($field, $value);
                break;

            default:
                $result = $this->getFieldValue($field, $value);
                break;
        }

        return $result;
    }
1267733
private function findSelectOptions($field)
    {
        \PHPUnit_Framework_Assert::assertNotNull(
            $select = $this->getPage()->findField($field),
            sprintf('The select field "%s" does not exist.', $field)
        );

        $options = [];

        foreach ($select->find('xpath', '/option') as $option) {
            $options[] = $option->getValue();
        }

        return $options;
    }
550246
private function mapToRelationshipAndAttribute(string $field): array
    {
        $rootSchema = $this->getRootSchema();
        if ($rootSchema->hasAttributeMapping($field) === true) {
            $relationship = null;
            $schema       = $rootSchema;
            $attribute    = new Attribute($field, $schema);

            return [$relationship, $attribute];
        } elseif ($rootSchema->hasRelationshipMapping($field) === true) {
            $fromSchema   = $rootSchema;
            $toSchema     = $this->getJsonSchemas()->getRelationshipSchema(get_class($fromSchema), $field);
            $relationship = new Relationship($field, $fromSchema, $toSchema);
            $attribute    = new Attribute($toSchema::RESOURCE_ID, $toSchema);

            return [$relationship, $attribute];
        } elseif (count($mightBeRelAndAttr = explode('.', $field, 2)) === 2) {
            // Last chance. It could be a dot ('.') separated relationship with an attribute.

            $mightBeRel  = $mightBeRelAndAttr[0];
            $mightBeAttr = $mightBeRelAndAttr[1];

            $fromSchema = $rootSchema;
            if ($fromSchema->hasRelationshipMapping($mightBeRel)) {
                $toSchema = $this->getJsonSchemas()->getRelationshipSchema(get_class($fromSchema), $mightBeRel);
                if ($toSchema::hasAttributeMapping($mightBeAttr) === true) {
                    $relationship = new Relationship($mightBeRel, $fromSchema, $toSchema);
                    $attribute    = new Attribute($mightBeAttr, $toSchema);

                    return [$relationship, $attribute];
                }
            }
        }

        $error = $this->createQueryError($field, static::MSG_ERR_INVALID_FIELD);
        throw new InvalidQueryParametersException($error);
    }
886790
protected function getOptions(FieldTypeInterface $field)
    {
        $options = parent::getOptions($field);

        $options['choices'] = $this->parseChoices($options['choices']);

        return $options;
    }
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;
    }
1350883
public function getFieldType($field)
    {
        return isset($this->getFieldsConfig()[$field]) ? $this->getFieldsConfig()[$field]['type'] : null;
    }
1050958
protected function getFieldValue(string $field, string $value): array
    {
        return [
            'type' => $this->searchFields[$field]['type'],
            'operator' => key($this->searchFields[$field]['operators']),
            'value' => $value
        ];
    }
1295418
protected function _getFieldValue($field, $useDefault = true)
    {
        $fieldOptions = static::$_classFields[get_called_class()][$field];

        if (isset($this->_record[$fieldOptions['columnName']])) {
            $value = $this->_record[$fieldOptions['columnName']];

            // apply type-dependent transformations
            switch ($fieldOptions['type']) {
                case 'password':
                {
                    return $value;
                }

                case 'timestamp':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        if ($value && $value != '0000-00-00 00:00:00') {
                            $this->_convertedValues[$field] = strtotime($value);
                        } else {
                            $this->_convertedValues[$field] = null;
                        }
                    }

                    return $this->_convertedValues[$field];
                }
                case 'serialized':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $this->_convertedValues[$field] = is_string($value) ? unserialize($value) : $value;
                    }

                    return $this->_convertedValues[$field];
                }
                case 'set':
                case 'list':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $delim = empty($fieldOptions['delimiter']) ? ',' : $fieldOptions['delimiter'];
                        $this->_convertedValues[$field] = array_filter(preg_split('/\s*'.$delim.'\s*/', $value));
                    }

                    return $this->_convertedValues[$field];
                }

                case 'boolean':
                {
                    if (!isset($this->_convertedValues[$field])) {
                        $this->_convertedValues[$field] = (boolean)$value;
                    }

                    return $this->_convertedValues[$field];
                }

                default:
                {
                    return $value;
                }
            }
        } elseif ($useDefault && isset($fieldOptions['default'])) {
            // return default
            return $fieldOptions['default'];
        } else {
            switch ($fieldOptions['type']) {
                case 'set':
                case 'list':
                {
                    return [];
                }
                default:
                {
                    return null;
                }
            }
        }
    }
1278870
public function getField($field)
    {
        // If we already have a value in $this->record, then we should just return that
        if (isset($this->record[$field])) {
            return $this->record[$field];
        }

        // Do we have a field that needs to be lazy loaded?
        if (isset($this->record[$field . '_Lazy'])) {
            $tableClass = $this->record[$field . '_Lazy'];
            $this->loadLazyFields($tableClass);
        }
        $schema = static::getSchema();

        // Support unary relations as fields
        if ($schema->unaryComponent(static::class, $field)) {
            return $this->getComponent($field);
        }

        // In case of complex fields, return the DBField object
        if ($schema->compositeField(static::class, $field)) {
            $this->record[$field] = $this->dbObject($field);
        }

        return isset($this->record[$field]) ? $this->record[$field] : null;
    }
532171
public function getOptionValue($field)
    {
        $postType = getPostType($this->getTable());
        if(!$postType) {
            throw new \Exception("Post type ".$this->getTable()."' does not exists!");
        }
        return $postType->getMultioptionFieldValue($field, $this->$field);
    }
35783
public function tagCloudTaxonomies($field)
    {
        $taxonomies = get_taxonomies(array('show_tagcloud' => true), 'object');

        foreach ($taxonomies as $key => $value) {
            $field['choices'][$key] = $value->labels->name;
        }

        return $field;
    }
113255
public function type($field)
    {
        $parts = explode('.', $field);
        $table = $this->_getTable($parts);

        return $table->getSchema()->baseColumnType(array_pop($parts));
    }
533942
public function getSelectRangeHtmlField(Field $field)
    {
        $stub = $this->getStubContent('form-selectrange-field.blade', $this->template);

        $this->replaceFieldName($stub, $field->name)
            ->replaceCssClass($stub, $field->cssClass)
            ->replaceFieldMinValue($stub, isset($field->range[0]) ? $field->range[0] : 1)
            ->replaceFieldMaxValue($stub, isset($field->range[1]) ? $field->range[1] : 10)
            ->replaceSelectedValue($stub, $this->getSelectedValueForMenu($field))
            ->replaceFieldPlaceHolder($stub, $this->getFieldPlaceHolderForMenu($field->getPlaceholder(), $field->name))
            ->wrapField($stub, $field);

        return $stub;
    }
812167
public function fields( $field = null, $option = null ) {

		$field_data = null;

		if ( empty( $this->fields ) ) {
			// No fields found.
			$field_data = array();
		} elseif ( empty( $field ) ) {
			// Return all fields.
			$field_data = (array) $this->fields;
		} elseif ( ! isset( $this->fields[ $field ] ) && ! isset( $this->pod_data['object_fields'][ $field ] ) ) {
			// Field not found.
			$field_data = array();
		} elseif ( empty( $option ) ) {
			// Return all field data.
			if ( isset( $this->fields[ $field ] ) ) {
				$field_data = $this->fields[ $field ];
			} elseif ( isset( $this->pod_data['object_fields'] ) ) {
				$field_data = $this->pod_data['object_fields'][ $field ];
			}
		} else {
			$options = array();

			// Merge options.
			if ( isset( $this->fields[ $field ] ) ) {
				$options = array_merge( $this->fields[ $field ], $this->fields[ $field ]['options'] );
			} elseif ( isset( $this->pod_data['object_fields'] ) ) {
				$options = array_merge( $this->pod_data['object_fields'][ $field ], $this->pod_data['object_fields'][ $field ]['options'] );
			}

			if ( 'data' === $option && in_array( pods_v( 'type', $options ), PodsForm::tableless_field_types(), true ) ) {
				// Get a list of available items from a relationship field.
				$field_data = PodsForm::field_method( 'pick', 'get_field_data', $options );
			} elseif ( isset( $options[ $option ] ) ) {
				// Return option.
				$field_data = $options[ $option ];
			}
		}//end if

		/**
		 * Modify the field data before returning
		 *
		 * @since unknown
		 *
		 * @param array       $field_data The data for the field.
		 * @param string|null $field      The specific field that data is being return for, if set when method is called or null.
		 * @param string|null $option     Value of option param when method was called. Can be used to get a list of available items from a relationship field.
		 * @param Pods|object $this       The current Pods class instance.
		 */
		return apply_filters( 'pods_pods_fields', $field_data, $field, $option, $this );

	}