/** * Gets directories where template files are stored for a generator class and a specific theme. * * @param string The generator class name * @param string The theme name * * @return array An array of directories */ public function getGeneratorTemplateDirs($class, $theme) { // if there is a configuration dimension if ($this->hasDimension()) { $cacheKey = sprintf('sf_generator_template_dirs_%s_%s', $class, $theme); // if there is a cache return it if ($this->dimension->getCache()->has($cacheKey)) { $dirs = $this->dimension->getCache()->get($cacheKey); } else { $dimensions = $this->dimension->getCascade(); // otherwise create and store $dirs = array(); if (is_readable(sfConfig::get('sf_data_dir') . '/generator/' . $class . '/' . $theme . '/template')) { $dir = sfConfig::get('sf_data_dir') . '/generator/' . $class . '/' . $theme . '/template'; // project // extend base dirs and add dimension cascade + checking dir exists foreach ($dimensions as $dimension) { if (is_readable($dir . '/' . $dimension)) { array_push($dirs, $dir . '/' . $dimension); } } array_push($dirs, $dir); } if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir') . '/*/data/generator/' . $class . '/' . $theme . '/template')) { foreach ($pluginDirs as $dir) { foreach ($dimensions as $dimension) { if (is_readable($dir . '/' . $dimension)) { array_push($dirs, $dir . '/' . $dimension); } } array_push($dirs, $dir); // plugin } } if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir') . '/plugins/*/data/generator/' . $class . '/' . $theme . '/template')) { $dirs = array_merge($dirs, $bundledPluginDirs); // bundled plugin } // save cache $this->dimension->getCache()->set($cacheKey, $dirs); } } else { $dirs = parent::getGeneratorTemplateDirs($class, $theme); } return $dirs; }