private function updateRelatedPostCloning(AbstractClassContent $content, array $cloningData, BBUserToken $token = null)
    {
        if (
                $content instanceof ContentSet &&
                true === array_key_exists('pages', $cloningData) &&
                true === array_key_exists('contents', $cloningData) &&
                0 < count($cloningData['pages']) &&
                0 < count($cloningData['contents'])
        ) {
            // reading copied elements
            $copied_pages = array_keys($cloningData['pages']);
            $copied_contents = array_keys($cloningData['contents']);

            // Updating subcontent if needed
            foreach ($content as $subcontent) {
                if (false === $this->_em->contains($subcontent)) {
                    $subcontent = $this->_em->find(get_class($subcontent), $subcontent->getUid());
                }

                if (
                        $subcontent instanceof AbstractClassContent &&
                        null !== $subcontent->getMainNode() &&
                        true === in_array($subcontent->getMainNode()->getUid(), $copied_pages) &&
                        true === in_array($subcontent->getUid(), $copied_contents)
                ) {
                    // Loading draft for content
                    if (
                            null !== $token &&
                            (null !== $draft = $this->_em->getRepository('BackBee\ClassContent\Revision')->getDraft($content, $token, true))
                        ) {
                        $content->setDraft($draft);
                    }
                    $content->replaceChildBy($subcontent, $cloningData['contents'][$subcontent->getUid()]);
                }
            }
        }

        return $this;
    }
private function updateRelatedPostCloning(AbstractClassContent $content, array $cloningData, BBUserToken $token = null)
    {
        if (
                $content instanceof ContentSet &&
                true === array_key_exists('pages', $cloningData) &&
                true === array_key_exists('contents', $cloningData) &&
                0 < count($cloningData['pages']) &&
                0 < count($cloningData['contents'])
        ) {
            // reading copied elements
            $copied_pages = array_keys($cloningData['pages']);
            $copied_contents = array_keys($cloningData['contents']);

            // Updating subcontent if needed
            foreach ($content as $subcontent) {
                if (false === $this->_em->contains($subcontent)) {
                    $subcontent = $this->_em->find(get_class($subcontent), $subcontent->getUid());
                }

                if (
                        $subcontent instanceof AbstractClassContent &&
                        null !== $subcontent->getMainNode() &&
                        true === in_array($subcontent->getMainNode()->getUid(), $copied_pages) &&
                        true === in_array($subcontent->getUid(), $copied_contents)
                ) {
                    // Loading draft for content
                    if (
                            null !== $token &&
                            (null !== $draft = $this->_em->getRepository('BackBee\ClassContent\Revision')->getDraft($content, $token, true))
                        ) {
                        $content->setDraft($draft);
                    }
                    $content->replaceChildBy($subcontent, $cloningData['contents'][$subcontent->getUid()]);
                }
            }
        }

        return $this;
    }
private function updateRelatedPostCloning ( AbstractClassContent $ content , array $ cloningData , BBUserToken $ token = null ) { if ( $ content instanceof ContentSet && true === array_key_exists ( 'pages' , $ cloningData ) && true === array_key_exists ( 'contents' , $ cloningData ) && 0 < count ( $ cloningData [ 'pages' ] ) && 0 < count ( $ cloningData [ 'contents' ] ) ) { // reading copied elements $ copied_pages = array_keys ( $ cloningData [ 'pages' ] ) ; $ copied_contents = array_keys ( $ cloningData [ 'contents' ] ) ; // Updating subcontent if needed foreach ( $ content as $ subcontent ) { if ( false === $ this -> _em -> contains ( $ subcontent ) ) { $ subcontent = $ this -> _em -> find ( get_class ( $ subcontent ) , $ subcontent -> getUid ( ) ) ; } if ( $ subcontent instanceof AbstractClassContent && null !== $ subcontent -> getMainNode ( ) && true === in_array ( $ subcontent -> getMainNode ( ) -> getUid ( ) , $ copied_pages ) && true === in_array ( $ subcontent -> getUid ( ) , $ copied_contents ) ) { // Loading draft for content if ( null !== $ token && ( null !== $ draft = $ this -> _em -> getRepository ( 'BackBee\ClassContent\Revision' ) -> getDraft ( $ content , $ token , true ) ) ) { $ content -> setDraft ( $ draft ) ; } $ content -> replaceChildBy ( $ subcontent , $ cloningData [ 'contents' ] [ $ subcontent -> getUid ( ) ] ) ; } } } return $ this ; }
Replace subcontent of ContentSet by their clone if exist.

@param  AbstractClassContent $content            The cloned content.
@param  array                $cloningData        The cloned data array.
@param  BBUserToken|null     $token              Optional, the BBuser token to allow the update of revisions if set.

@return PageRepository
Replace subcontent of ContentSet by their clone if exist .