public function updateByConfig(
        SectionConfig $sectionConfig,
        SectionInterface $section,
        bool $history = false
    ): SectionInterface {

        if ($history) {
            /** @var SectionInterface $sectionHistory */
            $sectionHistory = $this->copySectionDataToSectionHistoryEntity($section); // 1
            $sectionHistory->setVersioned(new \DateTime()); // 2
            $this->sectionHistoryManager->create($sectionHistory); // 2
            $version = $this->getHighestVersion($section->getHandle());
            $section->setVersion(1 + $version->toInt()); // 3
        }

        $section->removeFields(); // 4

        $fields = $this->fieldManager->readByHandles($sectionConfig->getFields()); // 5

        foreach ($fields as $field) {
            $section->addField($field);
        } // 6

        $section->setName((string) $sectionConfig->getName()); // 7
        $section->setHandle((string) $sectionConfig->getHandle()); // 7
        $section->setConfig($sectionConfig->toArray()); // 8

        $this->entityManager->persist($section); // 9
        $this->entityManager->flush(); // 9

        return $section;
    }