class ModelType extends Type implements ExtraTypeProvider (View source)

A type that is generated by a model

Traits

Used for a variety of classes that rely on SchemaModelInterface

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

A class that can be instantiated or replaced via DI

Allows adding, loading, and sorting of plugins

Properties

protected Field[] $fields from  Type

Methods

public static 
config()

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

public
mixed
stat(string $name) deprecated

Get inherited config value

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

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

Update the config value for a given property

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
addPlugin(string $pluginName, array $config = [])

No description

public
removePlugin(string $pluginName)

No description

public
mergePlugins(array $plugins)

No description

public
setPlugins(array $plugins)

No description

public
setDefaultPlugins(array $plugins)

No description

public
array
getPlugins(bool $inheritDefaults = true)

No description

public
array
getDefaultPlugins()

No description

public
bool
hasPlugin(string $identifier)

No description

public
getPluginRegistry()

No description

public
loadPlugins()

Translates all the ID and config settings to first class instances

public
array
getSortedPlugins()

Sorts the before/after of plugins using topological sort

public
__construct(SchemaModelInterface $model, array|null $config = [])

No description

public
mixed
applyConfig(array $config)

No description

public
string|null
getName()

No description

from  Type
public
setName(string $name)

No description

from  Type
public
array
getFields()

No description

from  Type
public
setFields(array $fields)

No description

from  Type
public
addField(string $fieldName, string|array|Field $fieldConfig = true, callable|null $callback = null)

No description

public
removeField(string $field)

No description

from  Type
public
Field|null
getFieldByName(string $fieldName)

No description

public
string|null
getDescription()

No description

from  Type
public
mergeWith(Type $type)

No description

public
void
validate()

No description

public
bool
exists()

No description

from  Type
public
setDescription(string|null $description)

No description

from  Type
public
array
getInterfaces()

No description

from  Type
public
string
getEncodedInterfaces()

No description

from  Type
public
setInterfaces(array $interfaces)

No description

from  Type
public
addInterface(string $name)

No description

from  Type
public
bool
implements(string $interfaceName)

No description

from  Type
public
bool
getIsInput()

No description

from  Type
public
setIsInput(bool $isInput)

No description

from  Type
public
ResolverReference|null
getFieldResolver()

No description

from  Type
public
setFieldResolver(array|string|ResolverReference|null $fieldResolver)

No description

from  Type
public
string
getSignature()

A deterministic representation of everything that gets encoded into the template.

from  Type
public
getModel()

No description

public
setModel(SchemaModelInterface $model)

No description

public
addFields(array $fields)

No description

public
addAllFields()

No description

public
addAllOperations()

No description

public
applyOperationsConfig(array $operations)

No description

public
addOperation(string $operationName, array $config = [])

No description

public
removeOperation(string $operationName)

No description

public
updateOperation(string $operationName, array $config = [])

No description

public
void
buildOperations()

No description

public
array
getOperations()

No description

public
array
getOperationCreators()

No description

public
array
getExtraTypes()

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

PluginConsumer addPlugin(string $pluginName, array $config = [])

No description

Parameters

string $pluginName
array $config

Return Value

PluginConsumer

PluginConsumer removePlugin(string $pluginName)

No description

Parameters

string $pluginName

Return Value

PluginConsumer

PluginConsumer mergePlugins(array $plugins)

No description

Parameters

array $plugins

Return Value

PluginConsumer

PluginConsumer setPlugins(array $plugins)

No description

Parameters

array $plugins

Return Value

PluginConsumer

Exceptions

SchemaBuilderException

PluginConsumer setDefaultPlugins(array $plugins)

No description

Parameters

array $plugins

Return Value

PluginConsumer

Exceptions

SchemaBuilderException

array getPlugins(bool $inheritDefaults = true)

No description

Parameters

bool $inheritDefaults

Return Value

array

array getDefaultPlugins()

No description

Return Value

array

bool hasPlugin(string $identifier)

No description

Parameters

string $identifier

Return Value

bool

PluginRegistry getPluginRegistry()

No description

Return Value

PluginRegistry

Generator loadPlugins()

Translates all the ID and config settings to first class instances

Return Value

Generator

Exceptions

SchemaBuilderException
CircularDependencyException
ElementNotFoundException

array getSortedPlugins()

Sorts the before/after of plugins using topological sort

Return Value

array

Exceptions

CircularDependencyException
ElementNotFoundException

__construct(SchemaModelInterface $model, array|null $config = [])

No description

Parameters

SchemaModelInterface $model
array|null $config

Exceptions

SchemaBuilderException

mixed applyConfig(array $config)

No description

Parameters

array $config

Return Value

mixed

Exceptions

SchemaBuilderException

string|null getName()

No description

Return Value

string|null

Type setName(string $name)

No description

Parameters

string $name

Return Value

Type

array getFields()

No description

Return Value

array

Type setFields(array $fields)

No description

Parameters

array $fields

Return Value

Type

Exceptions

SchemaBuilderException

Type addField(string $fieldName, string|array|Field $fieldConfig = true, callable|null $callback = null)

No description

Parameters

string $fieldName
string|array|Field $fieldConfig
callable|null $callback

Return Value

Type

Exceptions

SchemaBuilderException

Type removeField(string $field)

No description

Parameters

string $field

Return Value

Type

Field|null getFieldByName(string $fieldName)

No description

Parameters

string $fieldName

Return Value

Field|null

string|null getDescription()

No description

Return Value

string|null

Type mergeWith(Type $type)

No description

Parameters

Type $type

Return Value

Type

Exceptions

SchemaBuilderException

void validate()

No description

Return Value

void

Exceptions

SchemaBuilderException

bool exists()

No description

Return Value

bool

setDescription(string|null $description)

No description

Parameters

string|null $description

array getInterfaces()

No description

Return Value

array

string getEncodedInterfaces()

No description

Return Value

string

Type setInterfaces(array $interfaces)

No description

Parameters

array $interfaces

Return Value

Type

Type addInterface(string $name)

No description

Parameters

string $name

Return Value

Type

bool implements(string $interfaceName)

No description

Parameters

string $interfaceName

Return Value

bool

bool getIsInput()

No description

Return Value

bool

Type setIsInput(bool $isInput)

No description

Parameters

bool $isInput

Return Value

Type

ResolverReference|null getFieldResolver()

No description

Return Value

ResolverReference|null

Type setFieldResolver(array|string|ResolverReference|null $fieldResolver)

No description

Parameters

array|string|ResolverReference|null $fieldResolver

Return Value

Type

string getSignature()

A deterministic representation of everything that gets encoded into the template.

Used as a cache key. This method will need to be updated if new data is added to the generated code.

Return Value

string

Exceptions

Exception

SchemaModelInterface getModel()

No description

Return Value

SchemaModelInterface

ModelAware setModel(SchemaModelInterface $model)

No description

Parameters

SchemaModelInterface $model

Return Value

ModelAware

ModelType addFields(array $fields)

No description

Parameters

array $fields

Return Value

ModelType

Exceptions

SchemaBuilderException

ModelType addAllFields()

No description

Return Value

ModelType

Exceptions

SchemaBuilderException

ModelType addAllOperations()

No description

Return Value

ModelType

Exceptions

SchemaBuilderException

ModelType applyOperationsConfig(array $operations)

No description

Parameters

array $operations

Return Value

ModelType

Exceptions

SchemaBuilderException

ModelType addOperation(string $operationName, array $config = [])

No description

Parameters

string $operationName
array $config

Return Value

ModelType

ModelType removeOperation(string $operationName)

No description

Parameters

string $operationName

Return Value

ModelType

ModelType updateOperation(string $operationName, array $config = [])

No description

Parameters

string $operationName
array $config

Return Value

ModelType

Exceptions

SchemaBuilderException

void buildOperations()

No description

Return Value

void

Exceptions

SchemaBuilderException

array getOperations()

No description

Return Value

array

array getOperationCreators()

No description

Return Value

array

array getExtraTypes()

No description

Return Value

array

Exceptions

SchemaBuilderException