Bolt\Storage\ContentRequest\Save::action PHP Метод

action() публичный Метод

Do the save for a POSTed record.
public action ( array $formValues, array $contenttype, integer $id, boolean $new, string $returnTo, string $editReferrer ) : Response
$formValues array
$contenttype array The contenttype data
$id integer The record ID
$new boolean If TRUE this is a new record
$returnTo string
$editReferrer string
Результат Symfony\Component\HttpFoundation\Response
    public function action(array $formValues, array $contenttype, $id, $new, $returnTo, $editReferrer)
    {
        $contentTypeSlug = $contenttype['slug'];
        $repo = $this->em->getRepository($contentTypeSlug);
        // If we have an ID now, this is an existing record
        if ($id) {
            $content = $repo->find($id);
            $oldContent = clone $content;
            $oldStatus = $content['status'];
        } else {
            $content = $repo->create(['contenttype' => $contentTypeSlug, 'status' => $contenttype['default_status']]);
            $oldContent = null;
            $oldStatus = 'draft';
        }
        // Don't allow spoofing the ID.
        if ($content->getId() !== null && (int) $id !== $content->getId()) {
            if ($returnTo === 'ajax') {
                throw new AccessControlException("Don't try to spoof the id!");
            }
            $this->loggerFlash->error("Don't try to spoof the id!");
            return new RedirectResponse($this->generateUrl('dashboard'));
        }
        $this->setPostedValues($content, $formValues, $contenttype);
        $this->setTransitionStatus($content, $contentTypeSlug, $id, $oldStatus);
        // Get the associated record change comment
        $comment = isset($formValues['changelog-comment']) ? $formValues['changelog-comment'] : '';
        // Save the record
        return $this->saveContentRecord($content, $oldContent, $contenttype, $new, $comment, $returnTo, $editReferrer);
    }