Example #1
0
 /**
  * Parse the config files and save the values in the cache and in memory
  * 
  * @return void
  */
 public function build()
 {
     $files = $this->filesystem->listFiles($this->directory);
     $this->cache->clear();
     foreach ($files as $file) {
         if ($file['extension'] == 'yml' || $file['extension'] == 'yaml') {
             $this->cache->put($file['filename'], $this->yaml->parse($this->filesystem->read($file['path'])));
         }
     }
     $this->cache->persist();
     $this->updateValues();
 }
Example #2
0
 /**
  * @param  array $file
  * @return \GibbonCms\Gibbon\Entities\Entity|null
  */
 protected function parseFile($file)
 {
     if ($file['extension'] != 'md') {
         return null;
     }
     $id = preg_replace("/{$this->directory}\\/([^.]+).md/", '\\1', $file['path']);
     $entity = null;
     try {
         $entity = $this->factory->make(['id' => $id, 'data' => $this->filesystem->read($file['path'])]);
     } catch (EntityParseException $e) {
         $this->handleEntityParseException($file['path']);
     }
     return $entity;
 }