Jarves\Configuration\Configs::getConfigHash PHP Метод

getConfigHash() публичный Метод

Returns a md5 hash of all jarves config files (Resources/config/jarves.*.xml).
public getConfigHash ( string $bundleName ) : string
$bundleName string
Результат string
    public function getConfigHash($bundleName)
    {
        $hash = [];
        $bundle = $this->getJarves()->getBundle($bundleName);
        foreach ($this->getConfigFiles($bundle) as $file) {
            $hash[] = filemtime($file);
        }
        return md5(implode('.', $hash));
    }

Usage Example

Пример #1
0
 /**
  * Loads all configurations from all registered bundles (BundleName/Resources/config/jarves*.xml)
  * @param Cacher $cacher
  *
  * @return null|callable returns a callable that should be called when config stuff have been registered
  */
 public function loadBundleConfigs(Cacher $cacher)
 {
     $cached = $cacher->getFastCache('core/configs');
     $bundles = array_keys($this->kernel->getBundles());
     $configs = new Configuration\Configs($this);
     $hashes = [];
     foreach ($bundles as $bundleName) {
         $hashes[] = $configs->getConfigHash($bundleName);
     }
     $hash = md5(implode('.', $hashes));
     if ($cached) {
         $cached = unserialize($cached);
         if (is_array($cached) && $cached['md5'] == $hash) {
             $this->configs = $cached['data'];
             $this->configs->setCore($this);
         }
     }
     if (!$this->configs) {
         $this->configs = new Configuration\Configs($this, $bundles);
         return function () use($hash, $cacher) {
             $cached = serialize(['md5' => $hash, 'data' => $this->configs]);
             $cacher->setFastCache('core/configs', $cached);
         };
     }
 }