code: protected function generateBlocks(array $blocks, $blocksDir, $targetDir)
      {
          $c = 1;
          $generatedBlocks = array();
          foreach ($blocks as $block) {
              $blockName = 'block' . $c;
              $fileName = sprintf('%s/%s.json', $blocksDir, $blockName);
              $generatedBlocks[] = $blockName;
  
              $value = $block;
              if (is_array($value)) {
                  $value = json_encode($block);
              }
  
              FilesystemTools::writeFile($fileName, $value);
              $c++;
          }
  
          $slotDefinition = array(
              'next' => $c,
              'blocks' => $generatedBlocks,
              'revision' => 1,
          );
          FilesystemTools::writeFile($targetDir . '/slot.json', json_encode($slotDefinition));
      }
docs: Generate blocks for the current slot
  @param array $blocks
  @param string $blocksDir
  @param string $targetDir