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


PHP Twig_Template::getTemplateName方法代码示例

本文整理汇总了PHP中Twig_Template::getTemplateName方法的典型用法代码示例。如果您正苦于以下问题:PHP Twig_Template::getTemplateName方法的具体用法?PHP Twig_Template::getTemplateName怎么用?PHP Twig_Template::getTemplateName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twig_Template的用法示例。


在下文中一共展示了Twig_Template::getTemplateName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addTemplate

 /**
  * @param Template $template
  */
 public function addTemplate(Template $template)
 {
     $this->templates[$template->getTemplateName()] = $template;
     /** @var Template $parent */
     if ($parent = $template->getParent([])) {
         $this->addTemplate($parent);
     }
 }
开发者ID:comphppuebla,项目名称:easy-forms,代码行数:11,代码来源:FormTheme.php

示例2: getTemplates

 protected function getTemplates(\Twig_Template $template)
 {
     $names = [];
     $names[] = $template->getTemplateName();
     if (false !== ($parent = $template->getParent([]))) {
         $names = array_merge($names, $this->getTemplates($parent));
     }
     return $names;
 }
开发者ID:foreverglory,项目名称:admin-bundle,代码行数:9,代码来源:TwigEngine.php

示例3: getTemplateSource

 private function getTemplateSource(\Twig_Template $template)
 {
     // Twig templates are not always stored in files, and so there is no
     // API to get the filename from a template name in a generic way.
     // The logic used here works only for templates stored in app/Resources/views
     // and referenced via the "filename.html.twig" notation, not via the "::filename.html.twig"
     // one or stored in bundles. This is enough for the needs of the demo app.
     $filePath = $this->kernelRootDir . '/Resources/views/' . $template->getTemplateName();
     $sourceCode = $template->getSource();
     // Temporary workaround for https://github.com/twigphp/Twig/issues/2011
     if (null === $sourceCode) {
         $sourceCode = @file_get_contents($filePath);
     }
     return ['file_path' => $filePath, 'starting_line' => 1, 'source_code' => $sourceCode];
 }
开发者ID:rasanga,项目名称:symfony-demo,代码行数:15,代码来源:SourceCodeExtension.php

示例4: getCode

    /**
     * Gets the code from the template
     * @param  Twig_Template $template
     * @return HTML          to display
     */
    public function getCode($template)
    {
        $controllerClass = get_class($this->controller[0]);
        if (class_exists('CG\\Core\\ClassUtils')) {
            $controllerClass = ClassUtils::getUserClass($controllerClass);
        }
        $methodName = $this->controller[1];
        $controllerLink = $this->githubLocator->getMethodClassLink($controllerClass, $methodName);
        $templateLink = $this->githubLocator->getTemplateLink($template->getTemplateName());
        $controller = $this->getControllerCode($controllerClass, $methodName);
        $template = $this->getTemplateCode($template);
        // remove the code block
        $template = str_replace('{% set code = code(_self) %}', '', $template);
        return <<<EOF
<h4><strong>Controller Code - <a href="{$controllerLink}">Github</a></strong></h4>
<pre class="prettyprint">{$controller}</pre>

<h4><strong>Template Code - <a href="{$templateLink}">Github</a></strong></h4>
<pre class="prettyprint">{$template}</pre>
EOF;
    }
开发者ID:arkmancetz,项目名称:showmethecode,代码行数:26,代码来源:ShowMeTheCodeExtension.php

示例5: getTemplateName

 /**
  * Gets the name of the main loaded template.
  *
  * @return string
  */
 public function getTemplateName()
 {
     return $this->template->getTemplateName();
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:9,代码来源:BoltResponse.php

示例6: getTemplateSource

 private function getTemplateSource(\Twig_Template $template)
 {
     return array('file_path' => $this->kernelRootDir . '/Resources/views/' . $template->getTemplateName(), 'starting_line' => 1, 'source_code' => $template->getSource());
 }
开发者ID:JusteLeblanc,项目名称:symfony-demo,代码行数:4,代码来源:SourceCodeExtension.php

示例7: callMacro

 /**
  * Calls macro in a template.
  *
  * @param Twig_Template $template        The template
  * @param string        $macro           The name of macro
  * @param array         $arguments       The arguments of macro
  * @param array         $namedNames      An array of names of arguments as keys
  * @param integer       $namedCount      The count of named arguments
  * @param integer       $positionalCount The count of positional arguments
  *
  * @return string The content of a macro
  *
  * @throws Twig_Error_Runtime if the macro is not defined
  * @throws Twig_Error_Runtime if the argument is defined twice
  * @throws Twig_Error_Runtime if the argument is unknown
  */
 protected function callMacro(Twig_Template $template, $macro, array $arguments, array $namedNames = array(), $namedCount = 0, $positionalCount = -1)
 {
     if (!isset($template->macros[$macro]['reflection'])) {
         if (!isset($template->macros[$macro])) {
             throw new Twig_Error_Runtime(sprintf('Macro "%s" is not defined in the template "%s".', $macro, $template->getTemplateName()));
         }
         $template->macros[$macro]['reflection'] = new ReflectionMethod($template, $template->macros[$macro]['method']);
     }
     if ($namedCount < 1) {
         return $template->macros[$macro]['reflection']->invokeArgs($template, $arguments);
     }
     $i = 0;
     $args = array();
     foreach ($template->macros[$macro]['arguments'] as $name => $value) {
         if (isset($namedNames[$name])) {
             if ($i < $positionalCount) {
                 throw new Twig_Error_Runtime(sprintf('Argument "%s" is defined twice for macro "%s" defined in the template "%s".', $name, $macro, $template->getTemplateName()));
             }
             $args[] = $arguments[$name];
             if (--$namedCount < 1) {
                 break;
             }
         } elseif ($i < $positionalCount) {
             $args[] = $arguments[$i];
         } else {
             $args[] = $value;
         }
         $i++;
     }
     if ($namedCount > 0) {
         $parameters = array_keys(array_diff_key($namedNames, $template->macros[$macro]['arguments']));
         throw new Twig_Error_Runtime(sprintf('Unknown argument%s "%s" for macro "%s" defined in the template "%s".', count($parameters) > 1 ? 's' : '', implode('", "', $parameters), $macro, $template->getTemplateName()));
     }
     return $template->macros[$macro]['reflection']->invokeArgs($template, $args);
 }
开发者ID:odilitime,项目名称:vichan,代码行数:51,代码来源:Template.php

示例8: output

    /**
     * @param FieldDescriptionInterface $fieldDescription
     * @param \Twig_Template            $template
     * @param array                     $parameters
     *
     * @return string
     */
    public function output(FieldDescriptionInterface $fieldDescription, \Twig_Template $template, array $parameters, \Twig_Environment $environment)
    {
        $content = $template->render($parameters);
        if ($environment->isDebug()) {
            $commentTemplate = <<<EOT

<!-- START
    fieldName: %s
    template: %s
    compiled template: %s
    -->
    %s
<!-- END - fieldName: %s -->
EOT;
            return sprintf($commentTemplate, $fieldDescription->getFieldName(), $fieldDescription->getTemplate(), $template->getTemplateName(), $content, $fieldDescription->getFieldName());
        }
        return $content;
    }
开发者ID:andrey1s,项目名称:SonataAdminBundle,代码行数:25,代码来源:SonataAdminExtension.php

示例9: output

 /**
  * @param FieldDescriptionInterface $fieldDescription
  * @param \Twig_Template            $template
  * @param array                     $parameters
  *
  * @return string
  */
 public function output(FieldDescriptionInterface $fieldDescription, \Twig_Template $template, array $parameters = array())
 {
     $content = $template->render($parameters);
     if ($this->environment->isDebug()) {
         return sprintf("\n<!-- START  \n  fieldName: %s\n  template: %s\n  compiled template: %s\n -->\n%s\n<!-- END - fieldName: %s -->", $fieldDescription->getFieldName(), $fieldDescription->getTemplate(), $template->getTemplateName(), $content, $fieldDescription->getFieldName());
     }
     return $content;
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:15,代码来源:SonataAdminExtension.php

示例10: enrichMetdata

 protected function enrichMetdata(\Twig_Template $template)
 {
     $this->context['metadata']['uri'] = $template->getTemplateName();
     $this->context['metadata']['lastmod'] = new \DateTime(sprintf('@%d', filemtime($this->app['twig']->getCacheFilename($template->getTemplateName()))));
 }
开发者ID:eexit,项目名称:smak,代码行数:5,代码来源:Engine.php

示例11: getUiPageSelf

 /**
  * @param \Twig_Template $scope
  * @param string         $name
  *
  * @return mixed
  */
 public function getUiPageSelf(\Twig_Template $scope, $name)
 {
     $file = $scope->getTemplateName();
     $pattern = '/ui\\:(.*):(.*)\\.html\\.twig/';
     return preg_replace($pattern, sprintf('ui:$1:%s.html.twig', $name), $file);
 }
开发者ID:liverbool,项目名称:dos-resource-bundle,代码行数:12,代码来源:Page.php


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