PHP code example of heyday / silverstripe-versioneddataobjects
1. Go to this page and download the library: Download heyday/silverstripe-versioneddataobjects 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/ */
heyday / silverstripe-versioneddataobjects example snippets
class Slice extends DataObject
{
private static $db = [
'Content' => 'Text'
];
private static $has_one = [
'Parent' => 'SiteTree'
];
private static $extensions = [
'Heyday\VersionedDataObjects\VersionedDataObject'
];
}
// ...
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab(
'Root.Slices',
new GridField(
'Slices',
'Slices',
$this->Slices(),
$config = GridFieldConfig_RelationEditor::create()
)
);
$config->removeComponentsByType('GridFieldDetailForm');
$config->addComponent(new Heyday\VersionedDataObjects\VersionedDataObjectDetailsForm());
return $fields;
}
// ...
class SliceAdmin extends Heyday\VersionedDataObjects\VersionedModelAdmin
{
private static $menu_title = 'Slices';
private static $url_segment = 'slice';
private static $managed_models = [
'Slice'
];
}
VersionedFoo::get()
->setDataQueryParam(['Versioned.stage' => 'Stage']);
VersionedReadingMode::setStageReadingMode();
// ... code that runs queries
VersionedReadingMode::restoreOriginalReadingMode();