mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
DOC Document requirements for Configurable trait
This commit is contained in:
commit
d4bc386b34
@ -54,12 +54,27 @@ This can be done by calling the static method [Config::inst()](api:SilverStripe\
|
||||
$config = Config::inst()->get('MyClass', 'property');
|
||||
```
|
||||
|
||||
Or through the `config()` object on the class.
|
||||
Or through the `config()` method on the class.
|
||||
|
||||
```php
|
||||
$config = $this->config()->get('property')';
|
||||
```
|
||||
|
||||
You may need to apply the [Configurable](api:SilverStripe\Core\Config\Configurable) trait in order to access the `config()` method.
|
||||
|
||||
**mysite/code/MyOtherClass.php**
|
||||
|
||||
```php
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
|
||||
class MyOtherClass
|
||||
{
|
||||
use Configurable;
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Note that by default `Config::inst()` returns only an immutable version of config. Use `Config::modify()`
|
||||
if it's necessary to alter class config. This is generally undesirable in most applications, as modification
|
||||
of the config can immediately have performance implications, so this should be used sparingly, or
|
||||
|
Loading…
x
Reference in New Issue
Block a user