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));
    }