private function addBlock($dir, array $options, $blockName)
 {
     $filename = sprintf('%s/blocks/%s.json', $dir, $blockName);
     $block = BlockFactory::createBlock($options["type"]);
     $block->setName($blockName);
     $block->setSlotName($options["slot"]);
     $blockClass = get_class($block);
     $encodedBlock = $this->serializer->serialize($block, 'json');
     $event = Dispatcher::dispatch(BlockEvents::BLOCK_ADDING, new BlockAddingEvent($this->serializer, $filename, $encodedBlock, $blockClass));
     $blockContent = $event->getFileContent();
     FilesystemTools::writeFile($filename, $blockContent);
     Dispatcher::dispatch(BlockEvents::BLOCK_ADDED, new BlockAddedEvent($this->serializer, $filename, $encodedBlock, $blockClass));
     return $blockContent;
 }
 private function doParseChildren(array $children)
 {
     $parsedChildren = array();
     foreach ($children as $child) {
         if (!array_key_exists("type", $child)) {
             // @codeCoverageIgnoreStart
             continue;
             // @codeCoverageIgnoreEnd
         }
         $block = BlockFactory::createBlock($child["type"]);
         $encodedBlock = $this->serializer->serialize($block, 'json');
         $updatedBlock = JsonTools::join($encodedBlock, $child);
         $block = $this->serializer->deserialize(json_encode($updatedBlock), get_class($block), 'json');
         $block->updateSource();
         $children = json_decode($this->serializer->serialize($block, 'json'), true);
         if (array_key_exists("children", $children)) {
             $children["children"] = $this->doParseChildren($children["children"]);
         }
         $parsedChildren[] = $children;
     }
     return $parsedChildren;
 }
 public function testBlockCreated()
 {
     $block = BlockFactory::createBlock('Link');
     $this->assertInstanceOf('\\RedKiteCms\\Block\\Link\\Core\\LinkBlock', $block);
 }