コード例 #1
0
ファイル: Discovery.php プロジェクト: rhys-mcguckin/discovery
 /**
  * Refreshes the underlying cache.
  */
 protected function refresh()
 {
     if ($this->cache->exists()) {
         return;
     }
     // Cycle through the differing sources.
     foreach ($this->sources as $source) {
         // Cycle through all the classes deined by the sources.
         foreach ($source->getClasses() as $class) {
             // Get the meta information from the source.
             if (!($metas = $source->getClass($class))) {
                 continue;
             }
             // Cycle through all the metas defined for a given class.
             foreach ($metas as $meta) {
                 // Check the existance of required fields.
                 if (empty($meta['type']) || empty($meta['subtype'])) {
                     continue;
                 }
                 // Ensure a valid meta class.
                 if (empty($meta['meta']) || !class_exists($meta['meta']) || !in_array('Discovery\\MetaInterface', class_implements($meta['meta']))) {
                     $meta['meta'] = 'Discovery\\Meta';
                 }
                 // Create object and add it to the cache.
                 $object = new $meta['meta']($class, $meta);
                 $this->cache->setMeta($object);
             }
         }
     }
 }