Craft\NeoController::actionRenderBlocks PHP Method

actionRenderBlocks() public method

public actionRenderBlocks ( )
    public function actionRenderBlocks()
    {
        $this->requireAjaxRequest();
        $this->requirePostRequest();
        $blocks = craft()->request->getPost('blocks');
        $namespace = craft()->request->getPost('namespace');
        $locale = craft()->request->getPost('locale');
        $renderedBlocks = [];
        foreach ($blocks as $rawBlock) {
            $type = craft()->neo->getBlockTypeById($rawBlock['type']);
            $block = new Neo_BlockModel();
            $block->modified = true;
            $block->typeId = $rawBlock['type'];
            $block->level = $rawBlock['level'];
            $block->enabled = isset($rawBlock['enabled']);
            $block->collapsed = isset($rawBlock['collapsed']);
            $block->locale = $locale;
            if (!empty($rawBlock['content'])) {
                $block->setContentFromPost($rawBlock['content']);
            }
            $renderedBlocks[] = ['type' => $type->id, 'level' => $block->level, 'enabled' => $block->enabled, 'collapsed' => $block->collapsed, 'tabs' => craft()->neo->renderBlockTabs($type, $block, $namespace)];
        }
        $this->returnJson(['success' => true, 'blocks' => $renderedBlocks]);
    }