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 {@link 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

Properties

static private callable $pluraliser

Methods

static Injectable
create(array ...$args)

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

static Injectable
singleton(string $class = null)

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

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

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

No description

mixed
applyConfig(array $schemaConfig)

Converts a configuration array to instance state.

createStoreableSchema()

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

bool
exists()

No description

string
getSchemaKey()

No description

getConfig()

No description

getState()

No description

addQuery(Field $query)

No description

addMutation(Field $mutation)

No description

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

No description

removeType(string $type)

No description

Type|null
getType(string $name)

No description

findOrMakeType(string $name)

No description

Type|null
getCanonicalType(string $typeName)

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

array
getModelTypesFromClass(string $class)

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

array
getTypes()

No description

getQueryType()

No description

getMutationType()

No description

Type|null
getTypeOrModel(string $name)

No description

addEnum(Enum $enum)

No description

removeEnum(string $name)

No description

array
getEnums()

No description

Enum|null
getEnum(string $name)

No description

array
getScalars()

No description

Scalar|null
getScalar(string $name)

No description

addScalar(Scalar $scalar)

No description

removeScalar(string $name)

No description

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

No description

ModelType|null
getModel(string $name)

No description

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

No description

removeModelByClassName(string $class)

No description

removeModel(string $name)

No description

ModelType|null
getModelByClassName(string $class)

No description

eagerLoad(string $name)

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

lazyLoad(string $name)

No description

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

No description

array
getModels()

No description

findOrMakeModel(string $class)

No description

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

No description

removeInterface(string $name)

No description

InterfaceType|null
getInterface(string $name)

No description

array
getInterfaces()

No description

array
getImplementorsOf(string $interfaceName)

No description

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

No description

removeUnion(string $name)

No description

UnionType|null
getUnion(string $name)

No description

array
getUnions()

No description

applyBulkLoader(AbstractBulkLoader $loader, array $modelConfig)

No description

applyBulkLoaders(BulkLoaderSet $loaders, array $modelConfig)

No description

static array
getInternalTypes()

No description

static bool
isInternalType(string $type)

No description

string
pluralise(string $typeName)

Pluralise a name

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

No description

static void
assertValidName(string|null $name)

No description

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

No description

Details

static Injectable create(array ...$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'); $list = SiteTree::get();

Parameters

array ...$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 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

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

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 {@link 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()

Return Value

bool

string getSchemaKey()

Return Value

string

SchemaConfig getConfig()

Return Value

SchemaConfig

Configuration getState()

Return Value

Configuration

Schema addQuery(Field $query)

Parameters

Field $query

Return Value

Schema

Schema addMutation(Field $mutation)

Parameters

Field $mutation

Return Value

Schema

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

Parameters

Type $type
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

Schema removeType(string $type)

Parameters

string $type

Return Value

Schema

Type|null getType(string $name)

Parameters

string $name

Return Value

Type|null

Type findOrMakeType(string $name)

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()

Return Value

array

Type getQueryType()

Return Value

Type

Type getMutationType()

Return Value

Type

Type|null getTypeOrModel(string $name)

Parameters

string $name

Return Value

Type|null

Schema addEnum(Enum $enum)

Parameters

Enum $enum

Return Value

Schema

Schema removeEnum(string $name)

Parameters

string $name

Return Value

Schema

array getEnums()

Return Value

array

Enum|null getEnum(string $name)

Parameters

string $name

Return Value

Enum|null

array getScalars()

Return Value

array

Scalar|null getScalar(string $name)

Parameters

string $name

Return Value

Scalar|null

Schema addScalar(Scalar $scalar)

Parameters

Scalar $scalar

Return Value

Schema

Schema removeScalar(string $name)

Parameters

string $name

Return Value

Schema

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

Parameters

ModelType $modelType
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

ModelType|null getModel(string $name)

Parameters

string $name

Return Value

ModelType|null

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

Parameters

string $class
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

Schema removeModelByClassName(string $class)

Parameters

string $class

Return Value

Schema

Schema removeModel(string $name)

Parameters

string $name

Return Value

Schema

ModelType|null getModelByClassName(string $class)

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)

Parameters

string $name

Return Value

Schema

Exceptions

SchemaBuilderException

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

Parameters

string $class
array $config

Return Value

ModelType|null

Exceptions

SchemaBuilderException

array getModels()

Return Value

array

ModelType findOrMakeModel(string $class)

Parameters

string $class

Return Value

ModelType

Exceptions

SchemaBuilderException

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

Parameters

InterfaceType $type
callable|null $callback

Return Value

Schema

Exceptions

SchemaBuilderException

Schema removeInterface(string $name)

Parameters

string $name

Return Value

Schema

InterfaceType|null getInterface(string $name)

Parameters

string $name

Return Value

InterfaceType|null

array getInterfaces()

Return Value

array

array getImplementorsOf(string $interfaceName)

Parameters

string $interfaceName

Return Value

array

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

Parameters

UnionType $union
callable|null $callback

Return Value

Schema

Schema removeUnion(string $name)

Parameters

string $name

Return Value

Schema

UnionType|null getUnion(string $name)

Parameters

string $name

Return Value

UnionType|null

array getUnions()

Return Value

array

Schema applyBulkLoader(AbstractBulkLoader $loader, array $modelConfig)

Parameters

AbstractBulkLoader $loader
array $modelConfig

Return Value

Schema

Exceptions

SchemaBuilderException

Schema applyBulkLoaders(BulkLoaderSet $loaders, array $modelConfig)

Parameters

BulkLoaderSet $loaders
array $modelConfig

Return Value

Schema

Exceptions

SchemaBuilderException

static array getInternalTypes()

Return Value

array

static bool isInternalType(string $type)

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 = [])

Parameters

array $config
$allowedKeys
$requiredKeys

Return Value

void

Exceptions

SchemaBuilderException

static void assertValidName(string|null $name)

Parameters

string|null $name

Return Value

void

Exceptions

SchemaBuilderException

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

Parameters

$test
string $message
mixed ...$params

Return Value

void

Exceptions

SchemaBuilderException