private function _populateEntryModel(Section $section, SectionSettings $sectionSettings, Request $request): Entry
    {
        // Create and populate the entry
        $entry = new Entry([
            'sectionId' => $section->id,
            'authorId' => Db::idByUid('{{%elements}}', $sectionSettings->authorUid),
            'siteId' => $request->getBodyParam('siteId'),
            'typeId' => $request->getBodyParam('typeId') ?? $section->getEntryTypes()[0]->id,
            'title' => $request->getBodyParam('title'),
            'slug' => $request->getBodyParam('slug'),
            'enabled' => (bool)$sectionSettings->enabledByDefault,
            'enabledForSite' => (bool)$request->getBodyParam('enabledForSite', true),
            'newParentId' => $request->getBodyParam('parentId'),
        ]);

        if (($postDate = $request->getBodyParam('postDate')) !== null) {
            $entry->postDate = DateTimeHelper::toDateTime($postDate) ?: null;
        }

        if (($expiryDate = $request->getBodyParam('expiryDate')) !== null) {
            $entry->expiryDate = DateTimeHelper::toDateTime($expiryDate) ?: null;
        }

        $fieldsLocation = $request->getParam('fieldsLocation', 'fields');
        $entry->setFieldValuesFromRequest($fieldsLocation);

        return $entry;
    }
private function _populateEntryModel(Section $section, SectionSettings $sectionSettings, Request $request): Entry
    {
        // Create and populate the entry
        $entry = new Entry([
            'sectionId' => $section->id,
            'authorId' => Db::idByUid('{{%elements}}', $sectionSettings->authorUid),
            'siteId' => $request->getBodyParam('siteId'),
            'typeId' => $request->getBodyParam('typeId') ?? $section->getEntryTypes()[0]->id,
            'title' => $request->getBodyParam('title'),
            'slug' => $request->getBodyParam('slug'),
            'enabled' => (bool)$sectionSettings->enabledByDefault,
            'enabledForSite' => (bool)$request->getBodyParam('enabledForSite', true),
            'newParentId' => $request->getBodyParam('parentId'),
        ]);

        if (($postDate = $request->getBodyParam('postDate')) !== null) {
            $entry->postDate = DateTimeHelper::toDateTime($postDate) ?: null;
        }

        if (($expiryDate = $request->getBodyParam('expiryDate')) !== null) {
            $entry->expiryDate = DateTimeHelper::toDateTime($expiryDate) ?: null;
        }

        $fieldsLocation = $request->getParam('fieldsLocation', 'fields');
        $entry->setFieldValuesFromRequest($fieldsLocation);

        return $entry;
    }
private function _populateEntryModel ( Section $ section , SectionSettings $ sectionSettings , Request $ request ) : Entry { // Create and populate the entry $ entry = new Entry ( [ 'sectionId' => $ section -> id , 'authorId' => Db :: idByUid ( '{{%elements}}' , $ sectionSettings -> authorUid ) , 'siteId' => $ request -> getBodyParam ( 'siteId' ) , 'typeId' => $ request -> getBodyParam ( 'typeId' ) ?? $ section -> getEntryTypes ( ) [ 0 ] -> id , 'title' => $ request -> getBodyParam ( 'title' ) , 'slug' => $ request -> getBodyParam ( 'slug' ) , 'enabled' => ( bool ) $ sectionSettings -> enabledByDefault , 'enabledForSite' => ( bool ) $ request -> getBodyParam ( 'enabledForSite' , true ) , 'newParentId' => $ request -> getBodyParam ( 'parentId' ) , ] ) ; if ( ( $ postDate = $ request -> getBodyParam ( 'postDate' ) ) !== null ) { $ entry -> postDate = DateTimeHelper :: toDateTime ( $ postDate ) ? : null ; } if ( ( $ expiryDate = $ request -> getBodyParam ( 'expiryDate' ) ) !== null ) { $ entry -> expiryDate = DateTimeHelper :: toDateTime ( $ expiryDate ) ? : null ; } $ fieldsLocation = $ request -> getParam ( 'fieldsLocation' , 'fields' ) ; $ entry -> setFieldValuesFromRequest ( $ fieldsLocation ) ; return $ entry ; }
Populates an EntryModel with post data.

@param Section $section
@param SectionSettings $sectionSettings
@param Request $request
@throws BadRequestHttpException if the requested section doesn't allow guest submissions
@return Entry
Populates an EntryModel with post data .