mirror of
https://github.com/jbcr/core.git
synced 2026-04-24 17:18:08 +02:00
Deleting users unsets the author of Content
This commit is contained in:
@@ -98,6 +98,12 @@ class UserEditController extends TwigAwareController implements BackendZone
|
||||
#$this->validateCsrf($request, 'useredit');
|
||||
|
||||
$this->em->remove($user);
|
||||
$contentArray = $this->getDoctrine()->getManager()->getRepository('Bolt\Entity\Content')->findBy(['author' => $user]);
|
||||
foreach($contentArray as $content){
|
||||
$content->setAuthor(null);
|
||||
$this->em->persist($content);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
$url = $this->urlGenerator->generate('bolt_users');
|
||||
|
||||
@@ -233,7 +233,7 @@ class Content
|
||||
return $this->getDefinition()->get('icon_one') ?: $this->getDefinition()->get('icon_many');
|
||||
}
|
||||
|
||||
public function getAuthor(): User
|
||||
public function getAuthor(): ?User
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
@@ -447,9 +447,11 @@ class Content
|
||||
/**
|
||||
* @Groups("get_content")
|
||||
*/
|
||||
public function getAuthorName(): string
|
||||
public function getAuthorName(): ?string
|
||||
{
|
||||
return $this->getAuthor()->getDisplayName();
|
||||
if(!$this->getAuthor() == null)
|
||||
return $this->getAuthor()->getDisplayName();
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getStatuses(): array
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
{% include '@bolt/_partials/fields/text.html.twig' with {
|
||||
'label' : 'field.author'|trans,
|
||||
'name' : 'author',
|
||||
'value' : record.author.displayName,
|
||||
'value' : record.author.displayName|default('undefined'),
|
||||
'disabled' : true
|
||||
} %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user