Example #1
0
 public function revertToDraft($blocks)
 {
     $single = !is_array($blocks) && $blocks instanceof BlockInterface;
     if ($single) {
         $blocks = array($blocks);
     }
     foreach ($blocks as $key => $block) {
         $currentRevision = $this->revisionManager->getCurrentRevision($block);
         $latestRevision = $this->revisionManager->getLatestRevision($block);
         if ($latestRevision !== false && $currentRevision < $latestRevision) {
             try {
                 $this->revisionManager->revert($block, $latestRevision);
             } catch (DeletedException $e) {
                 unset($blocks[$key]);
             }
         }
     }
     return $single ? array_shift($blocks) : $blocks;
 }