PHP code example of hchokshi / silverstripe-trait-config

1. Go to this page and download the library: Download hchokshi/silverstripe-trait-config library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hchokshi / silverstripe-trait-config example snippets




// ...

$kernel = new CoreKernel(BASE_PATH); // Already there from default SilverStripe install
TraitConfigTransformer::addToKernel($kernel); // Add this line



trait MyTrait {
    /**
     * @internal
     * @aliasConfig $db
     * @var array 
     */
    private static $_mytrait_db = [ // This could be called $a09sdf0asfoiasdfj - "@aliasConfig $db" is the important part
        // ...
    ];
}

class MyObject extends DataObject {
    use MyTrait;
    
    private static $db = [
        // ...
    ];
}