public static function decodeJsonContent($block, $assoc = true)
    {
        $content = $block;
        $blockType = null;
        if (is_object($block)) {
            $content = $block->getContent();
            $blockType = $block->getType();
        }

        $content = json_decode($content, $assoc);
        if (null === $content) {
            $blockTypeInfo = (null !== $blockType) ? ' for the block ' . $blockType . ' ' : '';

            $exception = array(
                'message' => 'exception_wrong_json_format',
                'parameters' => array(
                    '%blockTypeInfo%' => $blockTypeInfo,
                ),
            );
            throw new Exception\InvalidJsonFormatException(json_encode($exception));
        }

        return $content;
    }
public static function decodeJsonContent($block, $assoc = true)
    {
        $content = $block;
        $blockType = null;
        if (is_object($block)) {
            $content = $block->getContent();
            $blockType = $block->getType();
        }

        $content = json_decode($content, $assoc);
        if (null === $content) {
            $blockTypeInfo = (null !== $blockType) ? ' for the block ' . $blockType . ' ' : '';

            $exception = array(
                'message' => 'exception_wrong_json_format',
                'parameters' => array(
                    '%blockTypeInfo%' => $blockTypeInfo,
                ),
            );
            throw new Exception\InvalidJsonFormatException(json_encode($exception));
        }

        return $content;
    }
public static function decodeJsonContent ( $ block , $ assoc = true ) { $ content = $ block ; $ blockType = null ; if ( is_object ( $ block ) ) { $ content = $ block -> getContent ( ) ; $ blockType = $ block -> getType ( ) ; } $ content = json_decode ( $ content , $ assoc ) ; if ( null === $ content ) { $ blockTypeInfo = ( null !== $ blockType ) ? ' for the block ' . $ blockType . ' ' : '' ; $ exception = array ( 'message' => 'exception_wrong_json_format' , 'parameters' => array ( '%blockTypeInfo%' => $ blockTypeInfo , ) , ) ; throw new Exception \ InvalidJsonFormatException ( json_encode ( $ exception ) ) ; } return $ content ; }
Decodes a json content

@param  string|\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Model\Block $block
@param  boolean                                            $assoc
@return array|object                                       depends on assoc param
@throws Exception\InvalidJsonFormatException

@api
Decodes a json content