mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
DOCS: Remove BuildState documentation
This commit is contained in:
parent
f0ae5e96df
commit
caa224e37b
@ -17,16 +17,6 @@ Docs for the current stable version (3.x) can be found
|
|||||||
|
|
||||||
Often times, you'll need to know the name of the type given a class name. There's a bit of context to this.
|
Often times, you'll need to know the name of the type given a class name. There's a bit of context to this.
|
||||||
|
|
||||||
### Getting the type name at build time
|
|
||||||
|
|
||||||
If you need to know the name of the type _during the build_, e.g. creating the name of an operation, field, query, etc,
|
|
||||||
you should use the `Build::requireActiveBuild()` accessor. This will get you the schema that is currently being built,
|
|
||||||
and throw if no build is active. A more tolerant method is `getActiveBuild()` which will return null if no schema
|
|
||||||
is being built.
|
|
||||||
|
|
||||||
```php
|
|
||||||
Build::requireActiveBuild()->findOrMakeModel($className)->getName();
|
|
||||||
```
|
|
||||||
|
|
||||||
### Getting the type name from within your app
|
### Getting the type name from within your app
|
||||||
|
|
||||||
@ -34,20 +24,7 @@ If you need the type name during normal execution of your app, e.g. to display i
|
|||||||
on the cached typenames, which are persisted alongside your generated schema code.
|
on the cached typenames, which are persisted alongside your generated schema code.
|
||||||
|
|
||||||
```php
|
```php
|
||||||
Schema::create('default')->getTypeNameForClass($className);
|
SchemaFactory::get('default')->getTypeNameForClass($className);
|
||||||
```
|
|
||||||
|
|
||||||
### Why is there a difference?
|
|
||||||
|
|
||||||
It is expensive to load all of the schema config. The `getTypeNameForClass` function avoids the need to
|
|
||||||
load the config, and reads directly from the cache. To be clear, the following is functionally equivalent,
|
|
||||||
but slow:
|
|
||||||
|
|
||||||
```php
|
|
||||||
Schema::create('default')
|
|
||||||
->loadFromConfig()
|
|
||||||
->findOrMakeModel($className)
|
|
||||||
->getName();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Persisting queries
|
## Persisting queries
|
||||||
|
Loading…
Reference in New Issue
Block a user