/**
* @return bool
* @throws HasRelationException
*/
private function checkUse()
{
if (!count($this->checkUse)) {
return true;
}
foreach ($this->checkUse as $usage) {
$findRelations = $this->findRelations($usage);
if (count($findRelations) > 0) {
$relationStrings = [];
foreach ($findRelations as $relation) {
$relationRefl = new \ReflectionClass($relation);
$relationStrings[] = (string) $relation . '[' . $relationRefl->getShortName() . '-' . $usage['field'] . '#' . $relation->getId() . ']';
}
$hasRelationException = new HasRelationException();
$hasRelationException->setErrorMessage($this->translator->trans('deletion.remove_components_first', ['%field%' => "\n - " . implode("\n - ", $relationStrings)]));
throw $hasRelationException;
}
}
return true;
}