当前位置: 首页>>代码示例>>PHP>>正文


PHP sfLoader::getGeneratorTemplate方法代码示例

本文整理汇总了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;
 }
开发者ID:taryono,项目名称:school,代码行数:20,代码来源:sfGenerator.class.php

示例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;
 }
开发者ID:Daniel-Marynicz,项目名称:symfony1-legacy,代码行数:48,代码来源:sfCrudGenerator.class.php


注:本文中的sfLoader::getGeneratorTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。