本文整理匯總了PHP中Magento\Framework\View\FileSystem::getTemplateFileName方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileSystem::getTemplateFileName方法的具體用法?PHP FileSystem::getTemplateFileName怎麽用?PHP FileSystem::getTemplateFileName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\FileSystem
的用法示例。
在下文中一共展示了FileSystem::getTemplateFileName方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTemplateFileName
/**
* Get template filename
*
* @param string $template
* @param [] $params
* @return string|bool
*/
public function getTemplateFileName($template, $params = [])
{
$key = $template . '_' . serialize($params);
if (!isset($this->_templateFilesMap[$key])) {
$this->_templateFilesMap[$key] = $this->_viewFileSystem->getTemplateFileName($template, $params);
}
return $this->_templateFilesMap[$key];
}
示例2: render
/**
* Render data
*
* @param UiComponentInterface $view
* @param string $template
* @return string
*/
public function render(UiComponentInterface $view, $template = '')
{
$templateEngine = false;
if ($template) {
$extension = pathinfo($template, PATHINFO_EXTENSION);
$templateEngine = $this->templateEnginePool->get($extension);
}
if ($templateEngine) {
$path = $this->filesystem->getTemplateFileName($template);
$result = $templateEngine->render($view, $path);
} else {
$result = '';
}
return $result;
}
示例3: render
/**
* Render data
*
* @param UiComponentInterface $view
* @param string $template
* @return string
* @throws \Exception
*/
public function render(UiComponentInterface $view, $template = '')
{
$templateEngine = false;
if ($template) {
$extension = pathinfo($template, PATHINFO_EXTENSION);
$templateEngine = $this->templateEnginePool->get($extension);
}
if ($templateEngine) {
$path = $this->filesystem->getTemplateFileName($template);
$result = $templateEngine->render($view, $path);
} else {
$result = $this->getDataXml($view);
}
throw new \Exception('Please implement XML renderer');
}
示例4: generateLayoutUpdateXml
/**
* Generate layout update xml
*
* @param string $container
* @param string $templatePath
* @return string
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function generateLayoutUpdateXml($container, $templatePath = '')
{
$templateFilename = $this->_viewFileSystem->getTemplateFileName($templatePath, ['area' => $this->getArea(), 'themeId' => $this->getThemeId(), 'module' => \Magento\Framework\View\Element\AbstractBlock::extractModuleName($this->getType())]);
if (!$this->getId() && !$this->isCompleteToCreate() || $templatePath && !is_readable($templateFilename)) {
return '';
}
$parameters = $this->getWidgetParameters();
$xml = '<body><referenceContainer name="' . $container . '">';
$template = '';
if (isset($parameters['template'])) {
unset($parameters['template']);
}
if ($templatePath) {
$template = ' template="' . $templatePath . '"';
}
$hash = $this->mathRandom->getUniqueHash();
$xml .= '<block class="' . $this->getType() . '" name="' . $hash . '"' . $template . '>';
foreach ($parameters as $name => $value) {
if ($name == 'conditions') {
$name = 'conditions_encoded';
$value = $this->conditionsHelper->encode($value);
} elseif (is_array($value)) {
$value = implode(',', $value);
}
if ($name && strlen((string) $value)) {
$xml .= '<action method="setData">' . '<argument name="name" xsi:type="string">' . $name . '</argument>' . '<argument name="value" xsi:type="string">' . $this->_escaper->escapeHtml($value) . '</argument>' . '</action>';
}
}
$xml .= '</block></referenceContainer></body>';
return $xml;
}
示例5: getTemplateFile
/**
* Get absolute path to template
*
* @param string|null $template
* @return string
*/
public function getTemplateFile($template = null)
{
$params = ['module' => $this->getModuleName()];
$area = $this->getArea();
if ($area) {
$params['area'] = $area;
}
$templateName = $this->_viewFileSystem->getTemplateFileName($template ?: $this->getTemplate(), $params);
return $templateName;
}
示例6: renderPage
/**
* Render page template
*
* @return string
* @throws \Exception
*/
protected function renderPage()
{
$fileName = $this->viewFileSystem->getTemplateFileName($this->template);
if (!$fileName) {
throw new \InvalidArgumentException('Template "' . $this->template . '" is not found');
}
ob_start();
try {
extract($this->viewVars, EXTR_SKIP);
include $fileName;
} catch (\Exception $exception) {
ob_end_clean();
throw $exception;
}
$output = ob_get_clean();
return $output;
}
示例7: testGetTemplateFileName
public function testGetTemplateFileName()
{
$expected = '%s/frontend/Test/default/Magento_Catalog/templates/theme_template.phtml';
$actual = $this->_model->getTemplateFileName('Magento_Catalog::theme_template.phtml', []);
$this->_testExpectedVersusActualFilename($expected, $actual);
}