Required fields getter method.

Returns either just the field names or with their schema definition.

@param bool $withSchema Schema inclusion flag
@return mixed[]|string[]
326559
public static function getRequiredFields(bool $withSchema = false) : array
    {
        return $withSchema ? self::$_requiredFields : array_keys(self::$_requiredFields);
    }
1354440
public function getTypes()
    {
        $schema = StaticSchema::inst();
        $tree = array_merge(
            [$this->rootClass],
            $schema->getDescendants($this->rootClass)
        );

        return array_map(function ($class) use ($tree, $schema) {
            return $schema->typeNameForDataObject($class);
        }, $tree);
    }
1000226
public function getSchema(): Schema
    {
        if ($this->schema === null) {
            $this->schema = new Schema($this);
        }

        return $this->schema;
    }
165553
public function getFieldValues($with_nulls = true)
    {
        $request_values = $this->getRequest()->all();

        $values = [];
        foreach ($this->getAllAttributes() as $attribute) {
            $value = Arr::get($request_values, $attribute);
            if ($with_nulls || $value !== null) {
                Arr::set($values, $attribute, $value);
            }
        }

        // If this form is a child form, cherry pick a part
        if ($prefix = $this->getName()) {
            $prefix = $this->formHelper->transformToDotSyntax($prefix);
            $values = Arr::get($values, $prefix);
        }

        // Allow form-specific value alters
        $this->formHelper->alterFieldValues($this, $values);

        return $values;
    }
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);
    }
1171733
private function getMixinSchemas(SchemaDescriptor $schema)
    {
        $schemaIds = [];

        foreach ($schema->getMixins() as $mixin) {
            $schemaIds[] = $mixin->getId()->getCurieWithMajorRev();

            $schemaIds = array_merge(
                $schemaIds,
                $this->getExtendsSchemas($mixin),
                $this->getMixinSchemas($mixin)
            );
        }

        return $schemaIds;
    }
1359570
function GetSchema() {
		$this->LoadSchema();
		$schema = array(
			'_model' => $this->model,
			'_table' => $this->table,
		);
		$schema = array_merge($schema, $this->schema);
		$schema['_id'] = $this->schema['_id']['field'];
		$this->Trigger('getschema', $schema);
		return $schema;
	}
980248
public function getTableFields($table, $withPrefix = false)
    {
        $fullTable = $withPrefix ? $table : $this->getTable($table);
        if (isset($this->tableFields[$fullTable])) {
            return $this->tableFields[$fullTable];
        } else {
            $fields = array();
            switch ($this->driver) {
                case 'mysql':
                    $tableInfo = $this->fetchAll("SHOW COLUMNS FROM $fullTable");
                    $fields = $this->filter($tableInfo, 'Field');
                    break;

                case 'sqlite':
                    $tableInfo = $this->fetchAll("PRAGMA table_info($fullTable)");
                    $fields = $this->filter($tableInfo, 'name');
                    break;

                case 'pgsql':
                    $tableInfo = $this->fetchAll(
                        "SELECT column_name FROM INFORMATION_SCHEMA.COLUMNS
                        WHERE table_catalog = ? AND table_name = ?
                        ORDER BY dtd_identifier ASC",
                        array($this->dbname, $fullTable)
                    );
                    $fields = $this->filter($tableInfo, 'column_name');
            }
            if (empty($fields)) {
                // For SQLite and PostgreSQL
                throw new \PDOException(sprintf('Table or view "%s" not found', $fullTable));
            }
            return $this->tableFields[$table] = $fields;
        }
    }
144459
public function getSchema()
    {
        $schema = new Schema(['adapter' => $this->_adapter]);
        $tables = $this->getTables();
        foreach ($tables as $tableName) {
            $schema->addTable($this->getTable($tableName));
        }

        return $schema;
    }
178936
public function with($with)
    {
        if (is_string($with)) {
            if (strpos($with, ',') === false) {
                $with = [$with];
            } else {
                $with = (array)preg_split('#[\s,]+#', $with, -1, PREG_SPLIT_NO_EMPTY);
            }
        }

        $with = $this->_with ? array_merge($this->_with, $with) : $with;

        foreach ($with as $k => $v) {
            $name = is_string($k) ? $k : $v;
            if (($pos = strpos($name, '.')) === false) {
                continue;
            }
            $parent_name = substr($name, 0, $pos);
            $child_name = substr($name, $pos + 1);
            if (!isset($with[$parent_name])) {
                continue;
            }

            $parent_value = $with[$parent_name];
            if (!$parent_value instanceof QueryInterface) {
                $with[$parent_name] = $this->relationsManager->getQuery($this->_model, $parent_name, $parent_value);
            }

            $with[$parent_name]->with(is_int($k) ? [$child_name] : [$child_name => $v]);
            unset($with[$k]);
        }

        $this->_with = $with;

        return $this;
    }
494581
private function getDefinedTypesFromSchema(Schema $schema, array $definitionFileDirectories): array
    {
        $definedTypes = $this->definitionsParser->getGraphqlDefinitionFilePaths(
            $definitionFileDirectories['types']
        );

        foreach ($definedTypes as $key => $type) {
            $definedTypes[$key] = str_replace('.graphql', '', basename($type));
        }

        $internalTypes = [];
        /**
         * @var string $typeName
         * @var ObjectType $type
         */
        foreach ($schema->getTypeMap() as $typeName => $type) {
            if (! in_array($typeName, $definedTypes) || ! method_exists($type, 'getFields')) {
                continue;
            }

            /**
             * @var string $fieldName
             * @var FieldDefinition $fieldType
             */
            foreach ($type->getFields() as $fieldName => $fieldType) {
                $graphQLType = $fieldType->getType();

                //Every required field is defined by a parent 'NonNullType'
                if (method_exists($graphQLType, 'getWrappedType')) {
                    // Clone the field to prevent pass by reference,
                    // because we want to add a config value unique to this field.
                    $graphQLType = clone $graphQLType->getWrappedType();

                    //We want to know later on wether or not a field is required
                    $graphQLType->config['generator-required'] = true;
                }

                if (! in_array(get_class($graphQLType), $this->supportedGraphQLTypes)) {
                    continue;
                };

                // This retrieves the GraphQL type for this field from the webonyx/graphql-php package
                $internalTypes[$typeName][$fieldName] = $graphQLType;
            }
        }

        return $internalTypes;
    }
652307
public function getSchemaTables(): array
    {
        if (empty($this->db)) {
            return [];
        }
        $schemaTable = self::SCHEMA_TABLES;
        $where[]     = "TABLE_TYPE = 'BASE TABLE'";
        $where[]     = "TABLE_SCHEMA = '{$this->db}'";
        if (!empty($this->tablesEnabled)) {
            $tablesEnabled = array_map(function ($item) {
                return "'{$item}'";
            }, $this->tablesEnabled);
            $where[]       = 'TABLE_NAME IN (' . implode(',', $tablesEnabled) . ')';
        }
        if (!empty($this->tablesDisabled)) {
            $tablesDisabled = array_map(function ($item) {
                return "'{$item}'";
            }, $this->tablesDisabled);
            $where[]        = 'TABLE_NAME NOT IN (' . implode(',', $tablesDisabled) . ')';
        }
        $where = !empty($where) ? ' WHERE ' . implode(' AND ', $where) : null;

        $querySql = "SELECT `TABLE_NAME` AS `name`,`TABLE_COMMENT` as `comment` FROM {$schemaTable} {$where}";
        $this->dbHandler->prepare($querySql);
        $this->dbHandler->execute([]);
        $this->tables = $this->dbHandler->fetch();

        return !empty($this->tables) ? $this->tables : [];
    }
56439
protected static function getSchemaFields()
    {
        $attribute = 'schema-fields';

        if (!static::hasClassAttribute($attribute)) {
            $allFields = static::getAllFields();
            $excludeFields = static::getExcludeFields();
            $schemaFields = array_diff($allFields, $excludeFields);

            static::setClassAttribute($attribute, $schemaFields);
        }

        return static::getClassAttribute($attribute);
    }
1247174
protected function getSchemaArray()
    {
        // ToDo - schema is required?
        if($this->scaffoldCommandObj->option('schema') != null)
        {
            if ($schema = $this->scaffoldCommandObj->option('schema'))
            {
                return (new SchemaParser)->parse($schema);
            }
        }

        return [];
    }
263424
private function getSchema(): ?SchemaInterface
    {
        if (!empty($this->schema)) {
            return $this->schema;
        }

        if (!empty($this->options['schema'])) {
            //TODO check instance of
            $this->schema = $this->options['schema'];
            return $this->schema;
        }

        if (!empty($this->options['subSchema'])) {

            //TODO this is a dirty way of receiving the service
            $receiver = null;
            if ($this->serviceManager->has($this->options['subSchema'])) {
                $receiver = $this->serviceManager->get($this->options['subSchema']);
            }

            if (empty($receiver)) {
                foreach (\array_keys($this->serviceManager->getServiceManagerConfig()->getSubManagers()) as $subManager) {
                    if ($this->serviceManager->get($subManager)->has($this->options['subSchema'])) {
                        $receiver = $this->serviceManager->get($subManager)->get($this->options['subSchema']);
                        break;
                    }
                }
            }

            if (!($receiver instanceof SubSchemaReceiverInterface)) {
                throw new \Exception($this->options['subSchema'] . " must implement " . SubSchemaReceiverInterface::class);
            }

            $this->schema = $receiver->receiveSchema($this->options['subSchemaName'], $this->builder);
            return $this->schema;
        }

        //TODO Exception
    }
1145881
public function getJsonItemSchemas()
	{
		$list = [];

		foreach( $this->getControllers() as $name => $controller ) {
			$list[$name] = $controller->getItemSchema();
		}

		if( ( $json = json_encode( $list ) ) === null ) {
			throw new \RuntimeException( 'Unable to encode schemas to JSON' );
		}

		return $json;
	}
1094385
public function getFieldDefinition(Schema $schema, ObjectType $parentType, string $fieldName): ?Field
    {
        if ($fieldName === '__schema' && $schema->getQueryType() === $parentType) {
            return SchemaMetaFieldDefinition();
        }

        if ($fieldName === '__type' && $schema->getQueryType() === $parentType) {
            return TypeMetaFieldDefinition();
        }

        if ($fieldName === '__typename') {
            return TypeNameMetaFieldDefinition();
        }

        $fields = $parentType->getFields();

        return $fields[$fieldName] ?? null;
    }