From 496ee6fde5b8409c96e8fb88a734fb67105adc2b Mon Sep 17 00:00:00 2001 From: Bart van Gennep Date: Tue, 23 Feb 2016 11:59:58 +0100 Subject: [PATCH] Reset section model cache using reflection --- src/Services/Sections.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Services/Sections.php b/src/Services/Sections.php index 8b85ee02..05b1191e 100644 --- a/src/Services/Sections.php +++ b/src/Services/Sections.php @@ -178,6 +178,7 @@ public function import(array $sectionDefinitions, $force = false) Craft::log(Craft::t('Importing section `{name}`', ['name' => $sectionDefinition['name']])); $this->populateSection($section, $sectionDefinition, $sectionHandle); + $this->resetCraftFieldsSectionModelCache($section); // Create initial section record if (!$this->preSaveSection($section)) { @@ -326,4 +327,17 @@ private function populateEntryType(EntryTypeModel $entryType, array $entryTypeDe $fieldLayout = Craft::app()->schematic_fields->getFieldLayout($entryTypeDefinition['fieldLayout']); $entryType->setFieldLayout($fieldLayout); } + + /** + * Reset craft section model cache using reflection + * @param SectionModel $section + */ + private function resetCraftFieldsSectionModelCache(SectionModel $section) + { + $obj = $section; + $refObject = new \ReflectionObject( $obj ); + $refProperty = $refObject->getProperty( '_entryTypes' ); + $refProperty->setAccessible( true ); + $refProperty->setValue($obj, null); + } }