private function clearSiteCaches()
    {
        $obj = Craft::$app->sites;
        $refObject = new \ReflectionObject($obj);
        if ($refObject->hasProperty('_sitesById')) {
            $refProperty1 = $refObject->getProperty('_sitesById');
            $refProperty1->setAccessible(true);
            $refProperty1->setValue($obj, null);
        }
        if ($refObject->hasProperty('_sitesByHandle')) {
            $refProperty2 = $refObject->getProperty('_sitesByHandle');
            $refProperty2->setAccessible(true);
            $refProperty2->setValue($obj, null);
        }
        $obj->init(); // reload sites
    }
private function clearSiteCaches()
    {
        $obj = Craft::$app->sites;
        $refObject = new \ReflectionObject($obj);
        if ($refObject->hasProperty('_sitesById')) {
            $refProperty1 = $refObject->getProperty('_sitesById');
            $refProperty1->setAccessible(true);
            $refProperty1->setValue($obj, null);
        }
        if ($refObject->hasProperty('_sitesByHandle')) {
            $refProperty2 = $refObject->getProperty('_sitesByHandle');
            $refProperty2->setAccessible(true);
            $refProperty2->setValue($obj, null);
        }
        $obj->init(); // reload sites
    }
private function clearSiteCaches ( ) { $ obj = Craft :: $ app -> sites ; $ refObject = new \ ReflectionObject ( $ obj ) ; if ( $ refObject -> hasProperty ( '_sitesById' ) ) { $ refProperty1 = $ refObject -> getProperty ( '_sitesById' ) ; $ refProperty1 -> setAccessible ( true ) ; $ refProperty1 -> setValue ( $ obj , null ) ; } if ( $ refObject -> hasProperty ( '_sitesByHandle' ) ) { $ refProperty2 = $ refObject -> getProperty ( '_sitesByHandle' ) ; $ refProperty2 -> setAccessible ( true ) ; $ refProperty2 -> setValue ( $ obj , null ) ; } $ obj -> init ( ) ; // reload sites }
Reset craft site service sites cache using reflection.
Reset craft site service sites cache using reflection .