framework/RedKiteCms/Content/BlockManager/BlockManagerEdit.php
public function edit($sourceDir, array $options, $username, $values)
    {
        $this->resolveOptions($options);
        $this->init($sourceDir, $options, $username);
        $this->createContributorDir($sourceDir, $options, $username);

        $filename = sprintf('%s/blocks/%s.json', $this->getDirInUse(), $options["blockname"]);
        $currentBlock = $options["baseBlock"] = JsonTools::jsonDecode(FilesystemTools::readFile($filename));

        $values = $this->parseChildren($values);

        $block = JsonTools::join($currentBlock, $values);
        $encodedBlock = json_encode($block);

        $blockClass = BlockFactory::getBlockClass($block["type"]);
        $event = Dispatcher::dispatch(
            BlockEvents::BLOCK_EDITING,
            new BlockEditingEvent($this->serializer, $filename, $encodedBlock, $blockClass)
        );
        $blockContent = $event->getFileContent();

        FilesystemTools::writeFile($filename, $blockContent);

        Dispatcher::dispatch(
            BlockEvents::BLOCK_EDITED,
            new BlockEditedEvent($this->serializer, $filename, $encodedBlock, $blockClass)
        );
        DataLogger::log(
            sprintf(
                'Block "%s" has been edited on the "%s" slot on page "%s" for the "%s_%s" language',
                $options["blockname"],
                $options["slot"],
                $options["page"],
                $options["language"],
                $options["country"]
            )
        );
    }
public function edit($sourceDir, array $options, $username, $values)
    {
        $this->resolveOptions($options);
        $this->init($sourceDir, $options, $username);
        $this->createContributorDir($sourceDir, $options, $username);

        $filename = sprintf('%s/blocks/%s.json', $this->getDirInUse(), $options["blockname"]);
        $currentBlock = $options["baseBlock"] = JsonTools::jsonDecode(FilesystemTools::readFile($filename));

        $values = $this->parseChildren($values);

        $block = JsonTools::join($currentBlock, $values);
        $encodedBlock = json_encode($block);

        $blockClass = BlockFactory::getBlockClass($block["type"]);
        $event = Dispatcher::dispatch(
            BlockEvents::BLOCK_EDITING,
            new BlockEditingEvent($this->serializer, $filename, $encodedBlock, $blockClass)
        );
        $blockContent = $event->getFileContent();

        FilesystemTools::writeFile($filename, $blockContent);

        Dispatcher::dispatch(
            BlockEvents::BLOCK_EDITED,
            new BlockEditedEvent($this->serializer, $filename, $encodedBlock, $blockClass)
        );
        DataLogger::log(
            sprintf(
                'Block "%s" has been edited on the "%s" slot on page "%s" for the "%s_%s" language',
                $options["blockname"],
                $options["slot"],
                $options["page"],
                $options["language"],
                $options["country"]
            )
        );
    }
Edits the given block

@param string $sourceDir
@param array $options
@param string $username
@param array $values