class StaticSchema (View source)

Global map of dataobject classes to graphql schema types.

Provides an automatic scaffold mechanism for any classes without explicit mapping.

This must be done globally and prior to scaffolding as type mapping must be determined before scaffolding begins.

Traits

Provides extensions to this object to integrate it with standard config API methods.

Constants

PREFER_UNION

PREFER_SINGLE

Properties

static private string $inheritanceTypeSuffix

Methods

static Config_ForClass
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

mixed
stat(string $name) deprecated

Get inherited config value

mixed
uninherited(string $name)

Gets the uninherited value for the given config option

$this
set_stat(string $name, mixed $value) deprecated

Update the config value for a given property

static StaticSchema
inst()

No description

static 
setInstance(StaticSchema $inst = null)

No description

static 
reset()

Removes the current instance

load(string $schemaName)

Boots the type names from config. No graphql request necessary.

string
typeNameForDataObject(string $class)

Given a DataObject subclass name, transform it into a sanitised (and implicitly unique) type name suitable for the GraphQL schema

string
inheritanceTypeNameForDataObject(string $class)

Gets the type name for a union type of all ancestors of a class given the classname

string
inheritanceTypeNameForType(string $typeName)

Gets the type name for a union type of all ancestors of a class given the type name

mixed
typeName(string $str)

No description

bool
isValidFieldName(ViewableData $instance, string $fieldName)

Returns true if the field name can be accessed on the given object

$this
setTypeNames(array $typesMap)

No description

array
getAncestry(string $dataObjectClass)

Gets all ancestors of a DataObject

array
getDescendants(string $dataObjectClass)

No description

Type
fetchFromManager(string $class, Manager $manager, int $mode = self::PREFER_UNION)

Gets the type from the manager given a DataObject class. Will use an inheritance type if available.

array
introspectTypes(Manager $manager)

No description

string
formatField(string $field)

No description

array
formatKeys(array $arr)

Formats all the keys of an array, preserving the values

array
extractKeys(array $keys, array $arr, bool $graceful = true)

Extracts the values for a list of keys

mixed
accessField(ViewableData $obj, $fieldName)

No description

callable
getFieldFormatter()

No description

Details

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed stat(string $name) deprecated

deprecated 5.0 Use ->config()->get() instead

Get inherited config value

Parameters

string $name

Return Value

mixed

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

$this set_stat(string $name, mixed $value) deprecated

deprecated 5.0 Use ->config()->set() instead

Update the config value for a given property

Parameters

string $name
mixed $value

Return Value

$this

static StaticSchema inst()

Return Value

StaticSchema

static setInstance(StaticSchema $inst = null)

Parameters

StaticSchema $inst

static reset()

Removes the current instance

StaticSchema load(string $schemaName)

Boots the type names from config. No graphql request necessary.

Parameters

string $schemaName

Return Value

StaticSchema

string typeNameForDataObject(string $class)

Given a DataObject subclass name, transform it into a sanitised (and implicitly unique) type name suitable for the GraphQL schema

Parameters

string $class

Return Value

string

string inheritanceTypeNameForDataObject(string $class)

Gets the type name for a union type of all ancestors of a class given the classname

Parameters

string $class

Return Value

string

string inheritanceTypeNameForType(string $typeName)

Gets the type name for a union type of all ancestors of a class given the type name

Parameters

string $typeName

Return Value

string

mixed typeName(string $str)

Parameters

string $str

Return Value

mixed

bool isValidFieldName(ViewableData $instance, string $fieldName)

Returns true if the field name can be accessed on the given object

Parameters

ViewableData $instance
string $fieldName

Return Value

bool

$this setTypeNames(array $typesMap)

Parameters

array $typesMap

An associate array of classname => type name

Return Value

$this

array getAncestry(string $dataObjectClass)

Gets all ancestors of a DataObject

Parameters

string $dataObjectClass

Return Value

array

array getDescendants(string $dataObjectClass)

Parameters

string $dataObjectClass

Return Value

array

Exceptions

InvalidArgumentException

Type fetchFromManager(string $class, Manager $manager, int $mode = self::PREFER_UNION)

Gets the type from the manager given a DataObject class. Will use an inheritance type if available.

Parameters

string $class
Manager $manager
int $mode

Return Value

Type

array introspectTypes(Manager $manager)

Parameters

Manager $manager

Return Value

array

Exceptions

Exception

string formatField(string $field)

Parameters

string $field

Return Value

string

array formatKeys(array $arr)

Formats all the keys of an array, preserving the values

Parameters

array $arr

Return Value

array

array extractKeys(array $keys, array $arr, bool $graceful = true)

Extracts the values for a list of keys

Parameters

array $keys
array $arr
bool $graceful

Return Value

array

FieldAccessorInterface|null getFieldAccessor()

Return Value

FieldAccessorInterface|null

mixed accessField(ViewableData $obj, $fieldName)

Parameters

ViewableData $obj
$fieldName

Return Value

mixed

callable getFieldFormatter()

Return Value

callable