Пример #1
0
 /**
  * @param \obo\Carriers\EntityInformationCarrier $entityInformation
  * @return array
  */
 protected function loadInformationForEntity(\obo\Carriers\EntityInformationCarrier $entityInformation)
 {
     if (\obo\obo::$developerMode or $this->cache === null) {
         $information = $this->createInformationForEntity($entityInformation);
     } else {
         if (null === ($information = $this->cache->load($entityInformation->className))) {
             $this->cache->store($entityInformation->className, $information = $this->createInformationForEntity($entityInformation));
         }
     }
     return $this->informations[$entityInformation->className] = $information;
 }
Пример #2
0
 /**
  * @param string $className
  * @return \obo\Carriers\EntityInformationCarrier
  * @throws \obo\Exceptions\Exception
  */
 protected function loadClassInformationForEntityWithClassName($className)
 {
     if (\is_file($this->lockFilePath)) {
         $fp = \fopen($this->lockFilePath, "c+");
         if (!\flock($fp, \LOCK_EX)) {
             throw new \obo\Exceptions\Exception("Unable to acquire exclusive lock");
         }
         $this->validateCache();
         \flock($fp, \LOCK_UN);
         \fclose($fp);
     }
     if (!$this->cacheValidity or ($entityInformation = $this->cache->load($className)) === null) {
         $this->createCache();
         if (($entityInformation = $this->cache->load($className)) === null) {
             throw new \obo\Exceptions\Exception("Failed to load entity information cache for class {$className}. Possible cause could be that you can't write to the cache folder, folders with all models are not loaded, or you are missing a model directory in config file.");
         }
     } else {
         $entityInformation = $this->cache->load($className);
     }
     $this->registerRunTimeEventsForEntity($entityInformation);
     return $this->entitiesInformations[\ltrim($className, "\\")] = $entityInformation;
 }