示例#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
 /**
  * @return void
  * @throws \obo\Exceptions\Exception
  */
 public function createCache()
 {
     $entitiesList = [];
     $fp = \fopen($this->lockFilePath, "c+");
     if (!\flock($fp, LOCK_EX)) {
         throw new \obo\Exceptions\Exception("Unable to acquire exclusive lock");
     }
     foreach ($this->explorer->analyze($this->modelsDirs) as $className => $entityInformation) {
         $this->cache->store($className, $entityInformation);
         $entitiesList[] = $className;
     }
     $this->cache->store("entitiesList", $entitiesList);
     $this->cache->store("changesHash", $this->calculateChangesHash());
     $this->cacheValidity = true;
     \flock($fp, \LOCK_UN);
     \fclose($fp);
     @\unlink($this->lockFilePath);
 }