本文整理汇总了PHP中Text_Template::renderTo方法的典型用法代码示例。如果您正苦于以下问题:PHP Text_Template::renderTo方法的具体用法?PHP Text_Template::renderTo怎么用?PHP Text_Template::renderTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Text_Template
的用法示例。
在下文中一共展示了Text_Template::renderTo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderFile
/**
* @param AnalyzerFileResult $fileResult
*/
private function renderFile(AnalyzerFileResult $fileResult)
{
$tombstonesList = $this->renderTombstonesList($fileResult);
$sourceCode = $this->formatSourceCode($fileResult);
$relativeFilePath = PathNormalizer::makeRelativeTo($fileResult->getFile(), $this->sourceDir);
$this->fileTemplate->setVar(array('path_to_root' => './' . str_repeat('../', substr_count($relativeFilePath, '/')), 'full_path' => $fileResult->getFile(), 'breadcrumb' => $this->renderBreadcrumb($relativeFilePath), 'tombstones_list' => $tombstonesList, 'source_code' => $sourceCode, 'date' => date('r'), 'version' => Application::VERSION));
$reportFile = $this->reportDir . DIRECTORY_SEPARATOR . $relativeFilePath . '.html';
$reportDir = dirname($reportFile);
if (!is_dir($reportDir)) {
mkdir($reportDir, 0777, true);
}
$this->fileTemplate->renderTo($reportFile);
}
示例2: generate
/**
* @param AnalyzerResult $result
*/
public function generate(AnalyzerResult $result)
{
$tombstonesView = $this->renderTombstonesView($result);
$deletedView = $this->renderDeletedView($result);
$numUndead = count($result->getUndead());
$numDead = count($result->getDead());
$numDeleted = count($result->getDeleted());
$total = $numDead + $numUndead;
$deadPercent = $total ? $numDead / $total * 100 : 0;
$undeadPercent = $total ? $numUndead / $total * 100 : 0;
$this->dashboardTemplate->setVar(array('path_to_root' => './', 'tombstones_count' => $total, 'dead_count' => $numDead, 'undead_count' => $numUndead, 'deleted_count' => $numDeleted, 'dead_percent' => $deadPercent, 'undead_percent' => $undeadPercent, 'tombstones_view' => $tombstonesView, 'deleted_view' => $deletedView, 'full_path' => $this->sourceDir, 'version' => Application::VERSION, 'date' => date('r')));
$this->dashboardTemplate->renderTo($this->reportDir . DIRECTORY_SEPARATOR . 'dashboard.html');
}
示例3: render
/**
* @param ReleaseCollection $releases
*/
public function render(ReleaseCollection $releases)
{
$latestReleases = '';
foreach ($releases->latestReleasesSortedByPackageName() as $release) {
$latestReleases .= $this->renderRelease($release, true);
}
$allReleases = '';
foreach ($releases->allReleases() as $release) {
$allReleases .= $this->renderRelease($release);
}
$page = new \Text_Template(__DIR__ . '/../templates/page.html');
$page->setVar(['domain' => $this->domain(), 'latest_releases' => $latestReleases, 'all_releases' => $allReleases]);
$page->renderTo($this->target());
}
示例4: render
/**
* @param ReleaseCollection $releases
*/
public function render(ReleaseCollection $releases)
{
$feedTemplate = new \Text_Template(__DIR__ . '/../templates/feed.xml');
$feedItemTemplate = new \Text_Template(__DIR__ . '/../templates/item.xml');
$rdfList = '';
$rdfItems = '';
foreach ($releases->latestReleasesSortedByDate() as $release) {
$rdfList .= sprintf(' <rdf:li rdf:resource="%s/%s-%s.phar"/>' . "\n", $this->domain(), $release->package(), $release->version());
$feedItemTemplate->setVar(['domain' => $this->domain(), 'package' => $release->package(), 'version' => $release->version(), 'date' => $release->date(), 'content' => '']);
$rdfItems .= $feedItemTemplate->render();
}
$feedTemplate->setVar(['items_list' => $rdfList, 'items' => $rdfItems, 'domain' => $this->domain(), 'email' => $this->email()]);
$feedTemplate->renderTo($this->target());
}
示例5: resultPrintAfter
/**
* @param PrintResultEvent $printResultEvent
* @throws \Codeception\Exception\ModuleRequireException
*/
public function resultPrintAfter(PrintResultEvent $printResultEvent)
{
if (count($this->failedIdentifiers) > 0) {
$items = '';
$itemTemplate = new \Text_Template($this->config['templateFolder'] . 'Item.html');
foreach ($this->failedIdentifiers as $vars) {
$itemTemplate->setVar($vars);
$items .= $itemTemplate->render();
}
$pageTemplate = new \Text_Template($this->config['templateFolder'] . 'Page.html');
$pageTemplate->setVar(array('items' => $items));
$reportPath = $this->fileSystemUtil->getFailImageDirectory() . 'index.html';
$pageTemplate->renderTo($reportPath);
$printResultEvent->getPrinter()->write('Report has been created: ' . $reportPath . "\n");
}
}
示例6: renderDirectory
/**
* @param ResultDirectory $directory
*/
private function renderDirectory(ResultDirectory $directory)
{
$directoryPath = $directory->getPath();
$filesList = '';
foreach ($directory->getDirectories() as $subDir) {
$name = $subDir->getName();
$link = './' . $subDir->getName() . '/index.html';
$filesList .= $this->renderDirectoryItem($name, $link, $subDir);
}
foreach ($directory->getFiles() as $fileResult) {
$name = basename($fileResult->getFile());
$link = './' . $name . '.html';
$filesList .= $this->renderDirectoryItem($name, $link, $fileResult);
}
$this->directoryTemplate->setVar(array('path_to_root' => './' . str_repeat('../', substr_count($directoryPath, '/') + ($directoryPath ? 1 : 0)), 'full_path' => PathTools::makePathAbsolute($directoryPath, $this->sourceDir), 'breadcrumb' => $this->renderBreadcrumb($directoryPath), 'files_list' => $filesList, 'date' => date('r'), 'version' => Application::VERSION));
$reportFile = $this->reportDir . DIRECTORY_SEPARATOR . $directoryPath . '/index.html';
$reportDir = dirname($reportFile);
if (!is_dir($reportDir)) {
mkdir($reportDir, 0777, true);
}
$this->directoryTemplate->renderTo($reportFile);
}
示例7: renderDashboard
/**
* @param PHP_CodeCoverage_Report_HTML_Node_Directory $root
* @param string $file
* @param string $title
*/
protected function renderDashboard(PHP_CodeCoverage_Report_HTML_Node_Directory $root, $file, $title)
{
$classes = $this->classes($root);
$template = new Text_Template(PHP_CodeCoverage_Report_HTML::$templatePath . 'dashboard.html');
$template->setVar(array('title' => $title, 'charset' => $this->options['charset'], 'date' => date('D M j G:i:s T Y', $_SERVER['REQUEST_TIME']), 'version' => '@package_version@', 'php_version' => PHP_VERSION, 'generator' => $this->options['generator'], 'least_tested_methods' => $this->leastTestedMethods($classes), 'top_project_risks' => $this->topProjectRisks($classes), 'cc_values' => $this->classComplexity($classes), 'ccd_values' => $this->classCoverageDistribution($classes), 'backlink' => basename(str_replace('.dashboard', '', $file))));
$template->renderTo($file);
}
示例8: dirname
#!/usr/bin/env php
<?php
require dirname(__DIR__) . '/PHPUnit/Autoload.php';
$buffer = '';
$class = new ReflectionClass('PHPUnit_Framework_Assert');
$methods = array();
foreach ($class->getMethods() as $method) {
$docblock = $method->getDocComment();
$name = $method->getName();
if (strpos($name, 'assert') === 0 || strpos($docblock, '@return PHPUnit_Framework_Constraint') !== FALSE) {
$methods[$name] = array('class' => 'PHPUnit_Framework_Assert', 'docblock' => $docblock, 'sigDecl' => str_replace(array('= false', '= true'), array('= FALSE', '= TRUE'), PHPUnit_Util_Class::getMethodParameters($method)), 'sigCall' => PHPUnit_Util_Class::getMethodParameters($method, TRUE));
}
}
$class = new ReflectionClass('PHPUnit_Framework_TestCase');
foreach ($class->getMethods() as $method) {
$docblock = $method->getDocComment();
$name = $method->getName();
if (strpos($docblock, '@return PHPUnit_Framework_MockObject_Matcher') !== FALSE || strpos($docblock, '@return PHPUnit_Framework_MockObject_Stub') !== FALSE) {
$methods[$name] = array('class' => 'PHPUnit_Framework_TestCase', 'docblock' => $docblock, 'sigDecl' => str_replace(array('= false', '= true'), array('= FALSE', '= TRUE'), PHPUnit_Util_Class::getMethodParameters($method)), 'sigCall' => PHPUnit_Util_Class::getMethodParameters($method, TRUE));
}
}
ksort($methods);
foreach ($methods as $name => $data) {
$buffer .= sprintf("\n\n%s\nfunction %s(%s)\n{\n return call_user_func_array(\n '%s::%s',\n func_get_args()\n );\n}", str_replace(' ', '', $data['docblock']), $name, $data['sigDecl'], $data['class'], $name, $data['sigCall']);
}
$template = new Text_Template(dirname(__DIR__) . '/PHPUnit/Framework/Assert/Functions.php.in');
$template->setVar(array('functions' => $buffer));
$template->renderTo(dirname(__DIR__) . '/PHPUnit/Framework/Assert/Functions.php');
示例9: array
#!/usr/bin/env php
<?php
require_once 'PHPUnit/Framework/Assert.php';
require_once 'PHPUnit/Util/Class.php';
require_once 'Text/Template.php';
if ($argc == 3) {
$methods = array();
$class = new ReflectionClass('PHPUnit_Framework_Assert');
foreach ($class->getMethods() as $method) {
$name = $method->getName();
if (strpos($name, 'assert') === 0) {
$methods[$name] = str_replace(array('= false', '= true'), array('= FALSE', '= TRUE'), PHPUnit_Util_Class::getMethodParameters($method));
}
}
ksort($methods);
$rows = '';
foreach ($methods as $methodName => $methodArguments) {
$rows .= sprintf('
<row>
<indexterm><primary>%s()</primary></indexterm>
<entry><literal>%s(%s)</literal></entry>
</row>', $methodName, $methodName, $methodArguments);
}
$template = new Text_Template($argv[1]);
$template->setVar(array('rows' => $rows));
$template->renderTo($argv[2]);
}
示例10: ReflectionClass
#!/usr/bin/env php
<?php
require_once 'PHPUnit/Framework/Assert.php';
require_once 'PHPUnit/Util/Class.php';
require_once 'Text/Template.php';
$class = new ReflectionClass('PHPUnit_Framework_Assert');
$methods = array();
foreach ($class->getMethods() as $method) {
$docblock = $method->getDocComment();
$name = $method->getName();
if (strpos($name, 'assert') === 0 || strpos($docblock, '@return PHPUnit_Framework_Constraint') !== FALSE) {
$methods[$name] = array('docblock' => $docblock, 'sigDecl' => str_replace(array('= false', '= true'), array('= FALSE', '= TRUE'), PHPUnit_Util_Class::getMethodParameters($method)), 'sigCall' => PHPUnit_Util_Class::getMethodParameters($method, TRUE));
}
}
ksort($methods);
$buffer = '';
foreach ($methods as $name => $data) {
$buffer .= sprintf("\n\n%s\nfunction %s(%s)\n{\n PHPUnit_Framework_Assert::%s(%s);\n}", str_replace(' ', '', $data['docblock']), $name, $data['sigDecl'], $name, $data['sigCall']);
}
$template = new Text_Template('PHPUnit/Framework/Assert/Functions.php.in');
$template->setVar(array('functions' => $buffer));
$template->renderTo('PHPUnit/Framework/Assert/Functions.php');