示例#1
0
 protected static function createTwigLoader(Settings $settings)
 {
     if (!$settings->has('template_paths')) {
         throw new RuntimeError('Missing "template_paths" settings with template lookup locations.');
     }
     $template_paths = (array) $settings->get('template_paths', []);
     $loader = new FilesystemLoader($template_paths);
     if ($settings->has('allowed_template_extensions')) {
         $loader->setAllowedExtensions((array) $settings->get('allowed_template_extensions'));
     }
     if (!$settings->has('cache_scope')) {
         $loader->setScope(spl_object_hash($loader));
         // unique scope for each new loader instance
     } else {
         $loader->setScope($settings->get('cache_scope', FilesystemLoader::SCOPE_DEFAULT));
     }
     return $loader;
 }
示例#2
0
 /**
  * Returns whether the setting key exists or not.
  *
  * @param mixed $key key to check
  *
  * @return bool true, if key exists; false otherwise
  */
 public function has($key)
 {
     return $this->settings->has($key);
 }