Bolt\Storage\ContentRequest\Save::saveContentRecord PHP Method

saveContentRecord() private method

Commit the record to the database.
private saveContentRecord ( Content $content, Content | null $oldContent, array $contentType, boolean $new, string $comment, string $returnTo, string $editReferrer ) : Response
$content Bolt\Storage\Entity\Content
$oldContent Bolt\Storage\Entity\Content | null
$contentType array
$new boolean
$comment string
$returnTo string
$editReferrer string
return Symfony\Component\HttpFoundation\Response
    private function saveContentRecord(Entity\Content $content, $oldContent, array $contentType, $new, $comment, $returnTo, $editReferrer)
    {
        // Save the record
        $repo = $this->em->getRepository($contentType['slug']);
        // Update the date modified timestamp
        $content->setDatechanged('now');
        $repo->save($content);
        $id = $content->getId();
        // Create the change log entry if configured
        $this->logChange($contentType, $content->getId(), $content, $oldContent, $comment);
        // Log the change
        if ($new) {
            $this->loggerFlash->success(Trans::__('contenttypes.generic.saved-new', ['%contenttype%' => $contentType['slug']]));
            $this->loggerSystem->info('Created: ' . $content->getTitle(), ['event' => 'content']);
        } else {
            $this->loggerFlash->success(Trans::__('contenttypes.generic.saved-changes', ['%contenttype%' => $contentType['slug']]));
            $this->loggerSystem->info('Saved: ' . $content->getTitle(), ['event' => 'content']);
        }
        /*
         * We now only get a returnto parameter if we are saving a new
         * record and staying on the same page, i.e. "Save {contenttype}"
         */
        if ($returnTo) {
            if ($returnTo === 'new') {
                return new RedirectResponse($this->generateUrl('editcontent', ['contenttypeslug' => $contentType['slug'], 'id' => $id, '#' => $returnTo]));
            } elseif ($returnTo === 'saveandnew') {
                return new RedirectResponse($this->generateUrl('editcontent', ['contenttypeslug' => $contentType['slug'], '#' => $returnTo]));
            } elseif ($returnTo === 'ajax') {
                return $this->createJsonUpdate($content, true);
            } elseif ($returnTo === 'test') {
                return $this->createJsonUpdate($content, false);
            }
        }
        // No returnto, so we go back to the 'overview' for this contenttype.
        // check if a pager was set in the referrer - if yes go back there
        if ($editReferrer) {
            return new RedirectResponse($editReferrer);
        } else {
            return new RedirectResponse($this->generateUrl('overview', ['contenttypeslug' => $contentType['slug']]));
        }
    }