class Schema implements ConfigurationApplier (View source)

The main Schema definition. A docking station for all type, model and interface abstractions.

Applies plugins, validates, and persists to code.

Use SchemaBuilder to create functional instances of this type based on YAML configuration.

Traits

A class that can be instantiated or replaced via DI

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

Constants

SCHEMA_CONFIG

SOURCE

TYPES

QUERIES

MUTATIONS

BULK_LOAD

MODELS

INTERFACES

UNIONS

ENUMS

SCALARS

QUERY_TYPE

MUTATION_TYPE

ALL

Config options

pluraliser callable
verbose bool

Properties

Methods

public static 
create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public static 
config()

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

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public
__construct(string $schemaKey, SchemaConfig|null $schemaConfig = null)

No description

public
mixed
applyConfig(array $schemaConfig)

Converts a configuration array to instance state.

public
createStoreableSchema()

Creates a readonly object that can be used by a storage service.

public
bool
exists()

No description

public
string
getSchemaKey()

No description

public
getConfig()

No description

public
getState()

No description

public
addQuery(Field $query)

No description

public
addMutation(Field $mutation)

No description

public
addType(Type $type, callable|null $callback = null)

No description

public
removeType(string $type)

No description

public
Type|null
getType(string $name)

No description

public
findOrMakeType(string $name)

No description

public
Type|null
getCanonicalType(string $typeName)

Given a type name, try to resolve it to any model-implementing component

public
array
getModelTypesFromClass(string $class)

Gets all the models that were generated from a given ancestor, e.g. DataObject

public
array
getTypes()

No description

public
getQueryType()

No description

public
getMutationType()

No description

public
Type|null
getTypeOrModel(string $name)

No description

public
addEnum(Enum $enum)

No description

public
removeEnum(string $name)

No description

public
array
getEnums()

No description

public
Enum|null
getEnum(string $name)

No description

public
array
getScalars()

No description

public
Scalar|null
getScalar(string $name)

No description

public
addScalar(Scalar $scalar)

No description

public
removeScalar(string $name)

No description

public
addModel(ModelType $modelType, callable|null $callback = null)

No description

public
ModelType|null
getModel(string $name)

No description

public
addModelbyClassName(string $class, callable|null $callback = null)

No description

public
removeModelByClassName(string $class)

No description

public
removeModel(string $name)

No description

public
ModelType|null
getModelByClassName(string $class)

No description

public
eagerLoad(string $name)

Some types must be eagerly loaded into the schema if they cannot be discovered through introspection.

public
lazyLoad(string $name)

No description

public
ModelType|null
createModel(string $class, array $config = [])

No description

public
array
getModels()

No description

public
findOrMakeModel(string $class)

No description

public
addInterface(InterfaceType $type, callable|null $callback = null)

No description

public
removeInterface(string $name)

No description

public
InterfaceType|null
getInterface(string $name)

No description

public
array
getInterfaces()

No description

public
array
getImplementorsOf(string $interfaceName)

No description

public
addUnion(UnionType $union, callable|null $callback = null)

No description

public
removeUnion(string $name)

No description

public
UnionType|null
getUnion(string $name)

No description

public
array
getUnions()

No description

public
applyBulkLoader(AbstractBulkLoader $loader, array $modelConfig)

No description

public
applyBulkLoaders(BulkLoaderSet $loaders, array $modelConfig)

No description

public static 
array
getInternalTypes()

No description

public static 
bool
isInternalType(string $type)

No description

public
string
pluralise(string $typeName)

Pluralise a name

public static 
void
assertValidConfig(array $config, $allowedKeys = [], $requiredKeys = [])

No description

public static 
void
assertValidName(string|null $name)

No description

public static 
void
invariant($test, string $message = '', mixed ...$params)

No description

Details

static Injectable create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.

This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();

Parameters

mixed ...$args

Return Value

Injectable

static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

static Config_ForClass config()

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

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

__construct(string $schemaKey, SchemaConfig|null $schemaConfig = null)

No description

Parameters

string $schemaKey
SchemaConfig|null $schemaConfig

mixed applyConfig(array $schemaConfig)

Converts a configuration array to instance state.

This is only needed for deeper customisations, since the configuration is auto-discovered and applied through the SchemaBuilder::boot() step.

Parameters

array $schemaConfig

Return Value

mixed

Exceptions

SchemaBuilderException

StorableSchema createStoreableSchema()

Creates a readonly object that can be used by a storage service.

Processes all of the types, fields, models, etc to end up with a coherent, schema that can be validated and stored.

Return Value

StorableSchema

bool exists()

No description

Return Value

bool

string getSchemaKey()

No description

Return Value

string

SchemaConfig getConfig()

No description

Return Value

SchemaConfig

Configuration getState()

No description

Return Value

Configuration

Schema addQuery(Field $query)

No description

Parameters

Field $query

Return Value

Schema

Schema addMutation(Field $mutation)

No description

Parameters

Field $mutation

Return Value

Schema

Schema addType(Type $type, callable|null $callback = null)

No description

Parameters

Type $type
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

Schema removeType(string $type)

No description

Parameters

string $type

Return Value

Schema

Type|null getType(string $name)

No description

Parameters

string $name

Return Value

Type|null

Type findOrMakeType(string $name)

No description

Parameters

string $name

Return Value

Type

Exceptions

SchemaBuilderException

Type|null getCanonicalType(string $typeName)

Given a type name, try to resolve it to any model-implementing component

Parameters

string $typeName

Return Value

Type|null

array getModelTypesFromClass(string $class)

Gets all the models that were generated from a given ancestor, e.g. DataObject

Parameters

string $class

Return Value

array

array getTypes()

No description

Return Value

array

Type getQueryType()

No description

Return Value

Type

Type getMutationType()

No description

Return Value

Type

Type|null getTypeOrModel(string $name)

No description

Parameters

string $name

Return Value

Type|null

Schema addEnum(Enum $enum)

No description

Parameters

Enum $enum

Return Value

Schema

Schema removeEnum(string $name)

No description

Parameters

string $name

Return Value

Schema

array getEnums()

No description

Return Value

array

Enum|null getEnum(string $name)

No description

Parameters

string $name

Return Value

Enum|null

array getScalars()

No description

Return Value

array

Scalar|null getScalar(string $name)

No description

Parameters

string $name

Return Value

Scalar|null

Schema addScalar(Scalar $scalar)

No description

Parameters

Scalar $scalar

Return Value

Schema

Schema removeScalar(string $name)

No description

Parameters

string $name

Return Value

Schema

Schema addModel(ModelType $modelType, callable|null $callback = null)

No description

Parameters

ModelType $modelType
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

ModelType|null getModel(string $name)

No description

Parameters

string $name

Return Value

ModelType|null

Schema addModelbyClassName(string $class, callable|null $callback = null)

No description

Parameters

string $class
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

Schema removeModelByClassName(string $class)

No description

Parameters

string $class

Return Value

Schema

Schema removeModel(string $name)

No description

Parameters

string $name

Return Value

Schema

ModelType|null getModelByClassName(string $class)

No description

Parameters

string $class

Return Value

ModelType|null

Schema eagerLoad(string $name)

Some types must be eagerly loaded into the schema if they cannot be discovered through introspection.

This may include types that do not appear in any queries.

Parameters

string $name

Return Value

Schema

Exceptions

SchemaBuilderException

Schema lazyLoad(string $name)

No description

Parameters

string $name

Return Value

Schema

Exceptions

SchemaBuilderException

ModelType|null createModel(string $class, array $config = [])

No description

Parameters

string $class
array $config

Return Value

ModelType|null

Exceptions

SchemaBuilderException

array getModels()

No description

Return Value

array

ModelType findOrMakeModel(string $class)

No description

Parameters

string $class

Return Value

ModelType

Exceptions

SchemaBuilderException

Schema addInterface(InterfaceType $type, callable|null $callback = null)

No description

Parameters

InterfaceType $type
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

Schema removeInterface(string $name)

No description

Parameters

string $name

Return Value

Schema

InterfaceType|null getInterface(string $name)

No description

Parameters

string $name

Return Value

InterfaceType|null

array getInterfaces()

No description

Return Value

array

array getImplementorsOf(string $interfaceName)

No description

Parameters

string $interfaceName

Return Value

array

Schema addUnion(UnionType $union, callable|null $callback = null)

No description

Parameters

UnionType $union
callable|null $callback

Return Value

Schema

Schema removeUnion(string $name)

No description

Parameters

string $name

Return Value

Schema

UnionType|null getUnion(string $name)

No description

Parameters

string $name

Return Value

UnionType|null

array getUnions()

No description

Return Value

array

Schema applyBulkLoader(AbstractBulkLoader $loader, array $modelConfig)

No description

Parameters

AbstractBulkLoader $loader
array $modelConfig

Return Value

Schema

Exceptions

SchemaBuilderException

Schema applyBulkLoaders(BulkLoaderSet $loaders, array $modelConfig)

No description

Parameters

BulkLoaderSet $loaders
array $modelConfig

Return Value

Schema

Exceptions

SchemaBuilderException

static array getInternalTypes()

No description

Return Value

array

static bool isInternalType(string $type)

No description

Parameters

string $type

Return Value

bool

string pluralise(string $typeName)

Pluralise a name

Parameters

string $typeName

Return Value

string

Exceptions

SchemaBuilderException

static void assertValidConfig(array $config, $allowedKeys = [], $requiredKeys = [])

No description

Parameters

array $config
$allowedKeys
$requiredKeys

Return Value

void

Exceptions

SchemaBuilderException

static void assertValidName(string|null $name)

No description

Parameters

string|null $name

Return Value

void

Exceptions

SchemaBuilderException

static void invariant($test, string $message = '', mixed ...$params)

No description

Parameters

$test
string $message
mixed ...$params

Return Value

void

Exceptions

SchemaBuilderException