• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Twig_Template类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: renderBlock

 public function renderBlock(\Twig_Template $template, ColumnInterface $column, $object, $context, $blocks)
 {
     try {
         $value = $this->accessor->getValue($object, $column->getName());
     } catch (ExceptionInterface $exception) {
         $value = null;
     }
     $block = 'crudify_field_' . $column->getType();
     // check if the block exists
     $hasBlock = false;
     if (!isset($blocks[$block])) {
         $current = $template;
         do {
             if ($current->hasBlock($block)) {
                 break;
             }
             $current = $current->getParent($context);
         } while ($current instanceof \Twig_Template);
         if ($current instanceof \Twig_Template) {
             $hasBlock = true;
         }
     } else {
         $hasBlock = true;
     }
     if ($hasBlock) {
         $context['value'] = $value;
         $context['definition'] = $column->getParent()->getParent();
         $context['column'] = $column;
         $context['object'] = $object;
         $result = $template->renderBlock($block, $context, $blocks);
     } else {
         $result = htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
     }
     return $result;
 }
开发者ID:bravesheep,项目名称:crudify-bundle,代码行数:35,代码来源:CrudifyExtension.php


示例2: findAllBlocks

 public function findAllBlocks(\Twig_Template $template, array $context)
 {
     if (false !== ($parent = $template->getParent($context))) {
         return array_unique(array_merge($this->findAllBlocks($parent, $context), $template->getBlockNames()));
     }
     return $template->getBlockNames();
 }
开发者ID:georgjaehnig,项目名称:sculpin,代码行数:7,代码来源:TwigFormatter.php


示例3: renderTwigBlock

 protected function renderTwigBlock(\Twig_Template $template, $blockName, $context = array())
 {
     foreach ($template->getEnvironment()->getGlobals() as $key => $value) {
         if (!array_key_exists($key, $context)) {
             $context[$key] = $value;
         }
     }
     return $template->renderBlock($blockName, $context);
 }
开发者ID:phecho,项目名称:gitonomy,代码行数:9,代码来源:Mailer.php


示例4: set_lazy_block

 public function set_lazy_block(array &$context, \Twig_Template $tpl, $name, $key)
 {
     if (empty($key) || !is_string($key)) {
         throw new \Exception(sprintf("key(%s) must be string", json_encode($key)));
     }
     \Dev::shareCacheValue($key, function ($app) use(&$context, &$tpl, $name) {
         $tpl->displayBlock($name, $context);
     });
 }
开发者ID:symforce,项目名称:symforce-discuz,代码行数:9,代码来源:SymforceDiscuzTwigExtension.php


示例5: populateMessage

 /**
  * Fills in message using blocks from a template (`body`, `subject`, `from`).
  * If there is no `body` block then whole template will be used.
  * If there is no `subject` or `from` block then corresponding default value will be used.
  * @param \Swift_Message $message
  * @param \Twig_Template $templateContent
  * @param array $data
  */
 protected function populateMessage(\Swift_Message $message, \Twig_Template $templateContent, $data)
 {
     $body = $templateContent->hasBlock('body') ? $templateContent->renderBlock('body', $data) : $templateContent->render($data);
     $subject = $templateContent->hasBlock('subject') ? $templateContent->renderBlock('subject', $data) : $this->defaultSubject;
     $from = $templateContent->hasBlock('from') ? $templateContent->renderBlock('from', $data) : $this->defaultFrom;
     $message->setFrom($from)->setSubject($subject)->setBody($body, 'text/html', 'utf-8');
 }
开发者ID:syzygymsu,项目名称:syzygy-framework-bundle,代码行数:15,代码来源:Composer.php


示例6: it_prepares_email_properly

 function it_prepares_email_properly($mailer, $twigEnvironment, \Twig_Template $template)
 {
     $from = '[email protected]';
     $to = '[email protected]';
     $templateName = 'test-template';
     $context = array('dummy', 'context');
     $template->renderBlock('subject', $context)->shouldBeCalled();
     $template->renderBlock('body_text', $context)->shouldBeCalled();
     $template->renderBlock('body_html', $context)->shouldBeCalled();
     $twigEnvironment->mergeGlobals($context)->shouldBeCalled()->willReturn($context);
     $twigEnvironment->loadTemplate($templateName)->willReturn($template);
     $mailer->send(Argument::any())->shouldBeCalled();
     $this->sendEmail($templateName, $context, $from, $to);
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:14,代码来源:TwigSwiftMailerSpec.php


示例7: 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


示例8: renderBlock

 /**
  * {@inheritdoc}
  */
 public function renderBlock(FormView $view, $resource, $blockName, array $variables = array())
 {
     $cacheKey = $view->vars[self::CACHE_KEY_VAR];
     $context = $this->environment->mergeGlobals($variables);
     ob_start();
     // By contract,This method can only be called after getting the resource
     // (which is passed to the method). Getting a resource for the first time
     // (with an empty cache) is guaranteed to invoke loadResourcesFromTheme(),
     // where the property $template is initialized.
     // We do not call renderBlock here to avoid too many nested level calls
     // (XDebug limits the level to 100 by default)
     $this->template->displayBlock($blockName, $context, $this->resources[$cacheKey]);
     return ob_get_clean();
 }
开发者ID:NivalM,项目名称:VacantesJannaMotors,代码行数:17,代码来源:TwigRendererEngine.php


示例9: render

 /**
  * Render the current request action
  */
 public function render()
 {
     if (isset($this->controllerTemplate)) {
         if (isset($this->actionTemplate)) {
             return $this->controllerTemplate->render(['actionTemplate' => $this->actionTemplate->render([])]);
         } else {
             return $this->controllerTemplate->render([]);
         }
     } else {
         if (isset($this->actionTemplate)) {
             return $this->actionTemplate->render([]);
         }
     }
 }
开发者ID:nikolaidan,项目名称:lusoexpress,代码行数:17,代码来源:BaseController.php


示例10: __construct

 public function __construct(Twig_Environment $env)
 {
     parent::__construct($env);
     // line 1
     $this->parent = $this->loadTemplate("FOSUserBundle::layout.html.twig", "FOSUserBundle:Security:login.html.twig", 1);
     $this->blocks = array('fos_user_content' => array($this, 'block_fos_user_content'));
 }
开发者ID:JerryAimee,项目名称:symfony.github.io,代码行数:7,代码来源:c2f2214180f3ea8f45dab864794418ede5bab27483d7a16ed2be1468711eed93.php


示例11: __construct

 public function __construct(Twig_Environment $env)
 {
     parent::__construct($env);
     // line 1
     $this->parent = $this->loadTemplate("@WebProfiler/Profiler/layout.html.twig", "WebProfilerBundle:Collector:translation.html.twig", 1);
     $this->blocks = array('toolbar' => array($this, 'block_toolbar'), 'menu' => array($this, 'block_menu'), 'panel' => array($this, 'block_panel'), 'panelContent' => array($this, 'block_panelContent'));
 }
开发者ID:tsurune,项目名称:Pruebas,代码行数:7,代码来源:29fc25868eeeb7615ab16174079dd604d6d2cf9942d01cc4f7dc3119d9661129.php


示例12: __construct

 public function __construct(Twig_Environment $env)
 {
     parent::__construct($env);
     // line 1
     $this->parent = $this->loadTemplate("::base.html.twig", "LaisoArmBundle:Bloc:index.html.twig", 1);
     $this->blocks = array('title' => array($this, 'block_title'), 'breadcumbs' => array($this, 'block_breadcumbs'), 'body' => array($this, 'block_body'));
 }
开发者ID:gasikely2,项目名称:sgpec,代码行数:7,代码来源:dce453cf93c0612fd2263bd4f5d0838f66516d896c87c978f1bbfdbbc4efe979.php


示例13: __construct

 public function __construct(Twig_Environment $env)
 {
     parent::__construct($env);
     // line 1
     $this->parent = $this->loadTemplate("knp_menu_base.html.twig", "knp_menu.html.twig", 1);
     $this->blocks = array('compressed_root' => array($this, 'block_compressed_root'), 'root' => array($this, 'block_root'), 'list' => array($this, 'block_list'), 'children' => array($this, 'block_children'), 'item' => array($this, 'block_item'), 'linkElement' => array($this, 'block_linkElement'), 'spanElement' => array($this, 'block_spanElement'), 'label' => array($this, 'block_label'));
 }
开发者ID:KaanTolunayKilic,项目名称:miniBlog,代码行数:7,代码来源:ad7b17b6b800ad1b773e111b2b41da06c72db56ce0b0dc892d35079027b60dff.php


示例14: __construct

 public function __construct(Twig_Environment $env)
 {
     parent::__construct($env);
     // line 1
     $this->parent = $this->loadTemplate("AnnuaireBundle:Default:index.html.twig", "AnnuaireBundle:Template:enregistrer.html.twig", 1);
     $this->blocks = array('lienretour' => array($this, 'block_lienretour'), 'container' => array($this, 'block_container'));
 }
开发者ID:mkemiche,项目名称:Annuaire,代码行数:7,代码来源:83aa5c9dae6f431f92b4ac1e1d8e3b3aa92e60beb2f8f23288f1e4ea30269d88.php


示例15: __construct

 public function __construct(Twig_Environment $env)
 {
     parent::__construct($env);
     // line 1
     $this->parent = $this->loadTemplate("@block/block.html.twig", "block.html.twig", 1);
     $this->blocks = array();
 }
开发者ID:m-ark22,项目名称:bdlp,代码行数:7,代码来源:98d1d5296cbff6583eb9aed6f54391eae18b996444eeb586167dfe3955b08186.php


示例16: __construct

 public function __construct(Twig_Environment $env)
 {
     parent::__construct($env);
     // line 3
     $this->parent = $this->loadTemplate("::admin.html.twig", "AdminBundle:Enseignant:edit.html.twig", 3);
     $this->blocks = array('body' => array($this, 'block_body'));
 }
开发者ID:kradwane,项目名称:Fablab,代码行数:7,代码来源:beb46bb0cede015c311a399f042cadb0d1cab393be701cf5ed27ab4d60a2e496.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Twig_Test_NodeTestCase类代码示例发布时间:2022-05-23
下一篇:
PHP Twig_Parser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap