public function action(array $formValues, $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);
    }
public function action(array $formValues, $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);
    }
public function action ( array $ formValues , $ 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 ) ; }
Do the save for a POSTed record.

@param array $formValues
@param array|ContentType $contentType The ContentType data
@param int $id The record ID
@param bool $new If TRUE this is a new record
@param string $returnTo
@param string $editReferrer

@throws AccessControlException
@throws InvalidRepositoryException

@return Response
Do the save for a POSTed record .