Source of file CMSActionsHandler.php
Size: 1,142 Bytes - Last Modified: 2021-12-23T10:36:11+00:00
/var/www/docs.ssmods.com/process/src/src/Handler/Elemental/CMSActionsHandler.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | <?php namespace SilverStripe\Snapshots\Handler\Elemental; use DNADesign\Elemental\Models\BaseElement; use SilverStripe\EventDispatcher\Event\EventContextInterface; use SilverStripe\ORM\DataObject; use SilverStripe\Snapshots\Handler\HandlerAbstract; use SilverStripe\Snapshots\Snapshot; use SilverStripe\ORM\ValidationException; /** * Handles save, publish on individual blocks */ class CMSActionsHandler extends HandlerAbstract { /** * @param EventContextInterface $context * @return Snapshot|null * @throws ValidationException */ protected function createSnapshot(EventContextInterface $context): ?Snapshot { $action = $context->getAction(); if (!$action) { return null; } $request = $context->get('request'); if (!$request) { return null; } $id = $request->param('ID'); if (!$id) { return null; } $block = DataObject::get_by_id(BaseElement::class, $id); if (!$block) { return null; } return Snapshot::singleton()->createSnapshot($block); } } |