Utility Module for implementing the CQRS workflow within a SilverStripe application.
Read Payload Manifests defines the data to be stored on a class basis.
Example Manifest ($read_payload
):
class MyObject extends DataObject {
private static $db = [
'Title' => 'Varchar',
'Teaser => 'Text',
'Content => 'HTMLText'
];
private static $has_many = [
'Categories' => Category::class
];
private static $read_payload = [
'ID', // required
'Title' => 'CoolTitle' // required, maps to "CoolTitle()"
'Teaser' => false, // not required
'Content' => true, // required (non-shorthand)
'Author', // required (method value)
'Categories' => true, // required recursive relation table
'Tags' => [ // not required, maps to "getMyTags()"
'required' => false,
'mapping' => 'getMyTags'
]
];
public function CoolTitle() { ... }
public function Author() { ... }
public function getMyTags() { ... }
}
- ext-redis: PHP Redis extension
CustomDataObject:
extensions:
- CQRSExtension('ID', ['store' => 'RedisPayloadStoreHandler', 'db' => 1])
# Optional, defaults to the values below
RedisPayloadStoreHandler:
host: 127.0.0.1
port: 6379
default_db: 0
- ext-mongodb: PHP MongoDB extension
- mongodb/mongodb: MongoDB PHP Library
CustomDataObject:
extensions:
- CQRSExtension('ID', ['store' => 'MongoPayloadStoreHandler', 'db' => 'DB_NAME', 'collection' => 'COLLECTION_NAME'])
# Optional, defaults to the values below
MongoPayloadStoreHandler:
host: 127.0.0.1
port: 27017
- elasticsearch/elasticsearch: Elasticsearch PHP Client
CustomDataObject:
extensions:
- CQRSExtension('ID', ['store' => 'ElasticsearchPayloadStoreHandler', 'index' => 'INDEX_NAME'])
# Optional, defaults to localhost:9200
ElasticsearchPayloadStoreHandler:
hosts:
- localhost:9200
- { host: elastic.domain.tld, port: 443, scheme: https, user: USERNAME, pass: PASS }
- Julian Scheuchenzuber js@lvl51.de