/** * 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 $uuid * * @return Response */ private function getReferentialIntegrityResponse($webspace, $references, $uuid, $locale) { $data = ['structures' => [], 'other' => [], 'isDefault' => $this->defaultSnippetManager->isDefault($uuid)]; 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); }