protected function prepSaveData(&$data)
    {
        if (!is_array($data)) {
            $data = [];
        }

        ksort($data);

        $data['containers'] = [];
        $data['pageContainer'] = [];

        if (empty($data['plugins'])) {
            throw new InvalidArgumentException(
                'Save Data missing plugins .
                Please make sure the data you\'re attempting to save is correctly formatted.
            '
            );
        }

        foreach ($data['plugins'] as &$plugin) {
            $this->cleanSaveData($plugin['saveData']);

            /* Patch for a Json Bug */
            if (!empty($plugin['isSitewide'])
                && $plugin['isSitewide'] != 'false'
                && $plugin['isSitewide'] != '0'
            ) {
                $plugin['isSitewide'] = 1;
            } else {
                $plugin['isSitewide'] = 0;
            }

            if (empty($plugin['sitewideName'])) {
                $plugin['sitewideName'] = null;
            }

            $plugin['rank'] = (int)$plugin['rank'];
            $plugin['rowNumber'] = (int)$plugin['rowNumber'];
            $plugin['columnClass'] = (string)$plugin['columnClass'];

            $plugin['containerName'] = $plugin['containerId'];

            if ($plugin['containerType'] == 'layout') {
                $data['containers'][$plugin['containerId']][] = &$plugin;
            } else {
                $data['pageContainer'][] = &$plugin;
            }
        }
    }
protected function prepSaveData(&$data)
    {
        if (!is_array($data)) {
            $data = [];
        }

        ksort($data);

        $data['containers'] = [];
        $data['pageContainer'] = [];

        if (empty($data['plugins'])) {
            throw new InvalidArgumentException(
                'Save Data missing plugins .
                Please make sure the data you\'re attempting to save is correctly formatted.
            '
            );
        }

        foreach ($data['plugins'] as &$plugin) {
            $this->cleanSaveData($plugin['saveData']);

            /* Patch for a Json Bug */
            if (!empty($plugin['isSitewide'])
                && $plugin['isSitewide'] != 'false'
                && $plugin['isSitewide'] != '0'
            ) {
                $plugin['isSitewide'] = 1;
            } else {
                $plugin['isSitewide'] = 0;
            }

            if (empty($plugin['sitewideName'])) {
                $plugin['sitewideName'] = null;
            }

            $plugin['rank'] = (int)$plugin['rank'];
            $plugin['rowNumber'] = (int)$plugin['rowNumber'];
            $plugin['columnClass'] = (string)$plugin['columnClass'];

            $plugin['containerName'] = $plugin['containerId'];

            if ($plugin['containerType'] == 'layout') {
                $data['containers'][$plugin['containerId']][] = &$plugin;
            } else {
                $data['pageContainer'][] = &$plugin;
            }
        }
    }
protected function prepSaveData ( & $ data ) { if ( ! is_array ( $ data ) ) { $ data = [ ] ; } ksort ( $ data ) ; $ data [ 'containers' ] = [ ] ; $ data [ 'pageContainer' ] = [ ] ; if ( empty ( $ data [ 'plugins' ] ) ) { throw new InvalidArgumentException ( 'Save Data missing plugins .
                Please make sure the data you\'re attempting to save is correctly formatted.
            ' ) ; } foreach ( $ data [ 'plugins' ] as & $ plugin ) { $ this -> cleanSaveData ( $ plugin [ 'saveData' ] ) ; /* Patch for a Json Bug */ if ( ! empty ( $ plugin [ 'isSitewide' ] ) && $ plugin [ 'isSitewide' ] != 'false' && $ plugin [ 'isSitewide' ] != '0' ) { $ plugin [ 'isSitewide' ] = 1 ; } else { $ plugin [ 'isSitewide' ] = 0 ; } if ( empty ( $ plugin [ 'sitewideName' ] ) ) { $ plugin [ 'sitewideName' ] = null ; } $ plugin [ 'rank' ] = ( int ) $ plugin [ 'rank' ] ; $ plugin [ 'rowNumber' ] = ( int ) $ plugin [ 'rowNumber' ] ; $ plugin [ 'columnClass' ] = ( string ) $ plugin [ 'columnClass' ] ; $ plugin [ 'containerName' ] = $ plugin [ 'containerId' ] ; if ( $ plugin [ 'containerType' ] == 'layout' ) { $ data [ 'containers' ] [ $ plugin [ 'containerId' ] ] [ ] = & $ plugin ; } else { $ data [ 'pageContainer' ] [ ] = & $ plugin ; } } }
Prep and validate data array to save

@param $data

@throws InvalidArgumentException
Prep and validate data array to save