src/Sulu/Bundle/SnippetBundle/Controller/SnippetController.php
private function getReferentialIntegrityResponse($webspace, $references, $id, $locale)
    {
        $data = [
            'structures' => [],
            'other' => [],
            'isDefault' => $this->defaultSnippetManager->isDefault($id),
        ];

        foreach ($references as $reference) {
            if ($reference->getParent()->isNodeType('sulu:page')) {
                $content = $this->contentMapper->load(
                    $reference->getParent()->getIdentifier(),
                    $webspace,
                    $locale,
                    true
                );
                $data['structures'][] = $content->toArray();
            } else {
                $data['other'][] = $reference->getParent()->getPath();
            }
        }

        return new JsonResponse($data, 409);
    }
private function getReferentialIntegrityResponse($webspace, $references, $id, $locale)
    {
        $data = [
            'structures' => [],
            'other' => [],
            'isDefault' => $this->defaultSnippetManager->isDefault($id),
        ];

        foreach ($references as $reference) {
            if ($reference->getParent()->isNodeType('sulu:page')) {
                $content = $this->contentMapper->load(
                    $reference->getParent()->getIdentifier(),
                    $webspace,
                    $locale,
                    true
                );
                $data['structures'][] = $content->toArray();
            } else {
                $data['other'][] = $reference->getParent()->getPath();
            }
        }

        return new JsonResponse($data, 409);
    }
private function getReferentialIntegrityResponse ( $ webspace , $ references , $ id , $ locale ) { $ data = [ 'structures' => [ ] , 'other' => [ ] , 'isDefault' => $ this -> defaultSnippetManager -> isDefault ( $ id ) , ] ; foreach ( $ references as $ reference ) { if ( $ reference -> getParent ( ) -> isNodeType ( 'sulu:page' ) ) { $ content = $ this -> contentMapper -> load ( $ reference -> getParent ( ) -> getIdentifier ( ) , $ webspace , $ locale , true ) ; $ data [ 'structures' ] [ ] = $ content -> toArray ( ) ; } else { $ data [ 'other' ] [ ] = $ reference -> getParent ( ) -> getPath ( ) ; } } return new JsonResponse ( $ data , 409 ) ; }
Return a response for the case where there is an referential integrity violation.

It will return a 409 (Conflict) response with an array of structures which reference
the node and an array of "other" nodes (i.e. non-structures) which reference the node.

@param string $webspace
@param NodeInterface[] $references
@param string $id

@return Response
Return a response for the case where there is an referential integrity violation .