本文整理汇总了PHP中sfLoader::getGeneratorTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP sfLoader::getGeneratorTemplate方法的具体用法?PHP sfLoader::getGeneratorTemplate怎么用?PHP sfLoader::getGeneratorTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfLoader
的用法示例。
在下文中一共展示了sfLoader::getGeneratorTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: evalTemplate
/**
* Evaluates a template file.
*
* @param string The template file path
*
* @return string The evaluated template
*/
protected function evalTemplate($templateFile)
{
$templateFile = sfLoader::getGeneratorTemplate($this->getGeneratorClass(), $this->getTheme(), $templateFile);
// eval template file
ob_start();
require $templateFile;
$content = ob_get_clean();
// replace [?php and ?]
$content = $this->replacePhpMarks($content);
$retval = "<?php\n" . "// auto-generated by " . $this->getGeneratorClass() . "\n" . "// date: %s\n?>\n%s";
$retval = sprintf($retval, date('Y/m/d H:i:s'), $content);
return $retval;
}
示例2: generate
/**
* Generates classes and templates in cache.
*
* @param array The parameters
*
* @return string The data to put in configuration cache
*/
public function generate($params = array())
{
$this->params = $params;
$required_parameters = array('model_class', 'moduleName');
foreach ($required_parameters as $entry) {
if (!isset($this->params[$entry])) {
$error = 'You must specify a "%s"';
$error = sprintf($error, $entry);
throw new sfParseException($error);
}
}
$modelClass = $this->params['model_class'];
if (!class_exists($modelClass)) {
$error = 'Unable to scaffold unexistant model "%s"';
$error = sprintf($error, $modelClass);
throw new sfInitializationException($error);
}
$this->setScaffoldingClassName($modelClass);
// generated module name
$this->setGeneratedModuleName('auto' . ucfirst($this->params['moduleName']));
$this->setModuleName($this->params['moduleName']);
// get some model metadata
$this->loadMapBuilderClasses();
// load all primary keys
$this->loadPrimaryKeys();
// theme exists?
$theme = isset($this->params['theme']) ? $this->params['theme'] : 'default';
$themeDir = sfLoader::getGeneratorTemplate($this->getGeneratorClass(), $theme, '');
if (!is_dir($themeDir)) {
$error = 'The theme "%s" does not exist.';
$error = sprintf($error, $theme);
throw new sfConfigurationException($error);
}
$this->setTheme($theme);
$templateFiles = sfFinder::type('file')->ignore_version_control()->name('*.php')->relative()->in($themeDir . '/templates');
$configFiles = sfFinder::type('file')->ignore_version_control()->name('*.yml')->relative()->in($themeDir . '/config');
$this->generatePhpFiles($this->generatedModuleName, $templateFiles, $configFiles);
// require generated action class
$data = "require_once(sfConfig::get('sf_module_cache_dir').'/" . $this->generatedModuleName . "/actions/actions.class.php');\n";
return $data;
}