PHP code example of silverstripe / versioned-snapshots
1. Go to this page and download the library: Download silverstripe/versioned-snapshots 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/ */
silverstripe / versioned-snapshots example snippets
use SilverStripe\Snapshots\Handler\Form\SaveHandler;
use SilverStripe\EventDispatcher\Event\EventContextInterface;
use SilverStripe\Snapshots\Snapshot;
class MySaveHandler extends SaveHandler
{
protected function createSnapshot(EventContextInterface $context): ?Snapshot
{
//...
}
}
use SilverStripe\Snapshots\Dispatch\DispatcherLoaderInterface;
use SilverStripe\Snapshots\Dispatch\Dispatcher;
use SilverStripe\Snapshots\Handler\Form\SaveHandler;
class MyEventLoader implements DispatcherLoaderInterface
{
public function addToDispatcher(Dispatcher $dispatcher): void
{
$dispatcher->removeListenerByClassName('formSubmitted.save', SaveHandler::class);
}
}