NerdsAndCompany\Schematic\Services\Sections::preSaveSection PHP Method

preSaveSection() private method

Save the section manually if it is new to prevent craft from creating the default entry type In case of a single we do want the default entry type and do a normal save Todo: This method is a bit hackish, find a better way.
private preSaveSection ( Craft\SectionModel $section ) : mixed
$section Craft\SectionModel
return mixed
    private function preSaveSection(SectionModel $section)
    {
        if ($section->type != 'single' && !$section->id) {
            $sectionRecord = new SectionRecord();
            // Shared attributes
            $sectionRecord->name = $section->name;
            $sectionRecord->handle = $section->handle;
            $sectionRecord->type = $section->type;
            $sectionRecord->enableVersioning = $section->enableVersioning;
            if (!$sectionRecord->save()) {
                $section->addErrors(['errors' => $sectionRecord->getErrors()]);
                return false;
            }
            $section->id = $sectionRecord->id;
            return true;
        }
        return Craft::app()->sections->saveSection($section);
    }