Example #1
0
 /**
  * Warms up the configuration data cache.
  *
  * @param int $mode One of MODE_* constant
  */
 public function warmUpCache($mode = self::MODE_ALL)
 {
     if (!$this->configManager->isDatabaseReadyToWork()) {
         return;
     }
     $this->loadConfigurable($mode === self::MODE_CONFIGURABLE_ENTITY_ONLY);
     if ($mode === self::MODE_ALL) {
         // disallow to load new models
         $this->configModelLockObject->lock();
         try {
             $this->loadNonConfigurable();
             $this->loadVirtualFields();
             $this->configModelLockObject->unlock();
         } catch (\Exception $e) {
             $this->configModelLockObject->unlock();
             throw $e;
         }
     }
 }
Example #2
0
 /**
  * Makes sure that an entity model for the given class is loaded
  * or, if the class name is not specified, make sure that all entity models are loaded
  *
  * @param string|null $className
  */
 protected function ensureEntityCacheWarmed($className = null)
 {
     if ($this->lockObject->isLocked()) {
         return;
     }
     if (null === $this->entities) {
         $this->entities = [];
     }
     if ($className) {
         if (!array_key_exists($className, $this->entities)) {
             $this->entities[$className] = !$this->entitiesAreLoaded ? $this->loadEntityModel($className) : null;
         }
     } elseif (!$this->entitiesAreLoaded) {
         $entityModels = $this->loadEntityModels();
         foreach ($entityModels as $model) {
             $this->entities[$model->getClassName()] = $model;
         }
         $this->entitiesAreLoaded = true;
     }
 }