NerdsAndCompany\Schematic\Services\CategoryGroups::resetCraftCategoriesServiceCache PHP Method

resetCraftCategoriesServiceCache() private method

Reset craft fields service cache using reflection.
    private function resetCraftCategoriesServiceCache()
    {
        $obj = Craft::app()->categories;
        $refObject = new \ReflectionObject($obj);
        if ($refObject->hasProperty('_fetchedAllCategoryGroups')) {
            $refProperty = $refObject->getProperty('_fetchedAllCategoryGroups');
            $refProperty->setAccessible(true);
            $refProperty->setValue($obj, false);
        }
        if ($refObject->hasProperty('_categoryGroupsById')) {
            $refProperty = $refObject->getProperty('_categoryGroupsById');
            $refProperty->setAccessible(true);
            $refProperty->setValue($obj, array());
        }
    }