class Mutation extends Field (View source)

Defines a generic mutation

Traits

A class that can be instantiated or replaced via DI

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

Allows adding, loading, and sorting of plugins

Constants

DEFAULT_TYPE

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

Field constructor.

from  Field
public static 
array
parseName(string $def)

Negotiates a variety of syntax that can appear in a field name definition.

from  Field
public
mixed
applyConfig(array $config)

No description

from  Field
public
addArg(string $argName, null $config, callable|null $callback = null)

No description

from  Field
public
setArgs(array $args)

No description

from  Field
public
mergeWith(Field $field)

No description

from  Field
public
bool
isList()

No description

from  Field
public
bool
isRequired()

No description

from  Field
public
void
validate()

No description

from  Field
public
setType($type, bool $required = false)

No description

from  Field
public
setTypeAsModel(string $modelTypeDef)

No description

from  Field
public
string|null
getTypeAsModel()

No description

from  Field
public
string|null
getName()

No description

from  Field
public
setName(string $name)

No description

from  Field
public
string|null
getType()

No description

from  Field
public
array
getArgs()

No description

from  Field
public
getEncodedType()

No description

from  Field
public
string
getNamedType()

Gets the name of the type, ignoring any nonNull/listOf wrappers

from  Field
public
setNamedType(string $name)

[MyType!]! becomes [MyNewType!]!

from  Field
public
getEncodedResolver(string|null $typeName = null)

No description

from  Field
public
string|null
getDescription()

No description

from  Field
public
setDescription(string|null $description)

No description

from  Field
public
ResolverReference|null
getResolver()

No description

from  Field
public
setResolver(array|string|ResolverReference|null $resolver)

No description

from  Field
public
array|null
getResolverContext()

No description

from  Field
public
setResolverContext(array|null $resolverContext)

No description

from  Field
public
addResolverContext(string $key, $value)

No description

from  Field
public
addResolverMiddleware(array|string|ResolverReference|null $resolver, array|null $context = null)

No description

from  Field
public
addResolverAfterware(array|string|ResolverReference|null $resolver, array|null $context = null)

No description

from  Field
public
array
getResolverMiddlewares()

No description

from  Field
public
array
getResolverAfterwares()

No description

from  Field
public
string
getSignature()

No description

from  Field
public
void
validatePlugin(string $pluginName, $plugin)

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

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

Field constructor.

Parameters

string $name
array|string $config

Exceptions

SchemaBuilderException

static array parseName(string $def)

Negotiates a variety of syntax that can appear in a field name definition.

fieldName fieldName(arg1: String!, arg2: Int) fieldName(arg1: String! = "foo")

Parameters

string $def

Return Value

array

Exceptions

SchemaBuilderException

mixed applyConfig(array $config)

No description

Parameters

array $config

Return Value

mixed

Exceptions

SchemaBuilderException

Field addArg(string $argName, null $config, callable|null $callback = null)

No description

Parameters

string $argName
null $config
callable|null $callback

Return Value

Field

Field setArgs(array $args)

No description

Parameters

array $args

Return Value

Field

Exceptions

SchemaBuilderException

Field mergeWith(Field $field)

No description

Parameters

Field $field

Return Value

Field

bool isList()

No description

Return Value

bool

bool isRequired()

No description

Return Value

bool

void validate()

No description

Return Value

void

Exceptions

SchemaBuilderException

Field setType($type, bool $required = false)

No description

Parameters

$type
bool $required

Return Value

Field

Exceptions

SchemaBuilderException

Field setTypeAsModel(string $modelTypeDef)

No description

Parameters

string $modelTypeDef

Return Value

Field

string|null getTypeAsModel()

No description

Return Value

string|null

string|null getName()

No description

Return Value

string|null

Field setName(string $name)

No description

Parameters

string $name

Return Value

Field

string|null getType()

No description

Return Value

string|null

array getArgs()

No description

Return Value

array

EncodedType getEncodedType()

No description

Return Value

EncodedType

Exceptions

SchemaBuilderException

string getNamedType()

Gets the name of the type, ignoring any nonNull/listOf wrappers

Return Value

string

Field setNamedType(string $name)

[MyType!]! becomes [MyNewType!]!

Parameters

string $name

Return Value

Field

Exceptions

SchemaBuilderException

EncodedResolver getEncodedResolver(string|null $typeName = null)

No description

Parameters

string|null $typeName

Return Value

EncodedResolver

Exceptions

SchemaBuilderException

string|null getDescription()

No description

Return Value

string|null

Field setDescription(string|null $description)

No description

Parameters

string|null $description

Return Value

Field

ResolverReference|null getResolver()

No description

Return Value

ResolverReference|null

Field setResolver(array|string|ResolverReference|null $resolver)

No description

Parameters

array|string|ResolverReference|null $resolver

Return Value

Field

array|null getResolverContext()

No description

Return Value

array|null

Field setResolverContext(array|null $resolverContext)

No description

Parameters

array|null $resolverContext

Return Value

Field

Field addResolverContext(string $key, $value)

No description

Parameters

string $key
$value

Return Value

Field

Field addResolverMiddleware(array|string|ResolverReference|null $resolver, array|null $context = null)

No description

Parameters

array|string|ResolverReference|null $resolver
array|null $context

Return Value

Field

Field addResolverAfterware(array|string|ResolverReference|null $resolver, array|null $context = null)

No description

Parameters

array|string|ResolverReference|null $resolver
array|null $context

Return Value

Field

array getResolverMiddlewares()

No description

Return Value

array

array getResolverAfterwares()

No description

Return Value

array

string getSignature()

No description

Return Value

string

Exceptions

SchemaBuilderException
Exception

void validatePlugin(string $pluginName, $plugin)

No description

Parameters

string $pluginName
$plugin

Return Value

void

Exceptions

SchemaBuilderException