protected function manageCollection(array $values, $savedValues = null, $blockKey = null)
    {
        if (array_key_exists('Content', $values)) {
            $data = json_decode($values['Content'], true);
            if (null === $savedValues) {
                $savedValues = $this->decodeJsonContent($this->alBlock);
            }

            if ($data["operation"] == "add") {
                if (isset($data["item"])) {

                    $savedValues = $this->addItem($data, $savedValues);
                    if (false === $savedValues) {
                        return false;
                    }
                } else {
                    $savedValues[] = $data["value"];
                }
                $values = array("Content" => json_encode($savedValues));
            }

            if ($data["operation"] == "remove") {

                $savedValues = $this->deleteItem($data, $savedValues, $blockKey);
                if (false === $savedValues) {
                    return false;
                }

                $values = array("Content" => json_encode(array_values($savedValues)));
            }
        }

        return $values;
    }
protected function manageCollection(array $values, $savedValues = null, $blockKey = null)
    {
        if (array_key_exists('Content', $values)) {
            $data = json_decode($values['Content'], true);
            if (null === $savedValues) {
                $savedValues = $this->decodeJsonContent($this->alBlock);
            }

            if ($data["operation"] == "add") {
                if (isset($data["item"])) {

                    $savedValues = $this->addItem($data, $savedValues);
                    if (false === $savedValues) {
                        return false;
                    }
                } else {
                    $savedValues[] = $data["value"];
                }
                $values = array("Content" => json_encode($savedValues));
            }

            if ($data["operation"] == "remove") {

                $savedValues = $this->deleteItem($data, $savedValues, $blockKey);
                if (false === $savedValues) {
                    return false;
                }

                $values = array("Content" => json_encode(array_values($savedValues)));
            }
        }

        return $values;
    }
protected function manageCollection ( array $ values , $ savedValues = null , $ blockKey = null ) { if ( array_key_exists ( 'Content' , $ values ) ) { $ data = json_decode ( $ values [ 'Content' ] , true ) ; if ( null === $ savedValues ) { $ savedValues = $ this -> decodeJsonContent ( $ this -> alBlock ) ; } if ( $ data [ "operation" ] == "add" ) { if ( isset ( $ data [ "item" ] ) ) { $ savedValues = $ this -> addItem ( $ data , $ savedValues ) ; if ( false === $ savedValues ) { return false ; } } else { $ savedValues [ ] = $ data [ "value" ] ; } $ values = array ( "Content" => json_encode ( $ savedValues ) ) ; } if ( $ data [ "operation" ] == "remove" ) { $ savedValues = $ this -> deleteItem ( $ data , $ savedValues , $ blockKey ) ; if ( false === $ savedValues ) { return false ; } $ values = array ( "Content" => json_encode ( array_values ( $ savedValues ) ) ) ; } } return $ values ; }
Manages the json collection, adding and removing items collection from the json
block

@param  array         $values
@param  null|array    $savedValues
@param  null          $blockKey
@return array|boolean
Manages the json collection adding and removing items collection from the json block