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


PHP Twig_Template::hasBlock方法代码示例

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


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

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

示例2: renderBlock

 /**
  * Render block.
  *
  * @param \Twig_Environment $twig
  * @param                   $name
  * @param                   $parameters
  *
  * @return string
  */
 private function renderBlock(\Twig_Environment $twig, $name, $parameters)
 {
     // load template if needed
     if (is_null($this->template)) {
         // get template name
         if (is_null($this->theme)) {
             $this->theme = 'PlatinumPixsSimplePaginationBundle::blocks.html.twig';
         }
         $this->template = $twig->loadTemplate($this->theme);
     }
     if ($this->template->hasBlock($name)) {
         return $this->template->renderBlock($name, $parameters);
     } else {
         throw new \InvalidArgumentException(sprintf('Block "%s" doesn\'t exist in template "%s".', $name, $this->theme));
     }
 }
开发者ID:platinumpixs,项目名称:symfony2-simple-pagination,代码行数:25,代码来源:TwigExtension.php

示例3: tryToCache

 /**
  * @param Template $theme
  * @param string $block
  * @return Template | null
  */
 protected function tryToCache(Template $theme, $block)
 {
     if ($theme->hasBlock($block)) {
         $this->cache[$block] = $theme;
         return $theme;
     }
 }
开发者ID:comphppuebla,项目名称:easy-forms,代码行数:12,代码来源:FormTheme.php

示例4: getBlock

 protected function getBlock(\Twig_Template $template, $name)
 {
     if ($template->hasBlock($name)) {
         $blocks = $template->getBlocks();
         return $blocks[$name];
     } elseif (false !== ($parent = $template->getParent([]))) {
         return $this->getBlock($parent, $name);
     }
     return false;
 }
开发者ID:foreverglory,项目名称:admin-bundle,代码行数:10,代码来源:TwigEngine.php

示例5: findTemplateWithBlock

 /**
  * @param \Twig_Template $template
  * @param string $blockName
  * @return \Twig_Template|bool
  */
 private function findTemplateWithBlock(\Twig_Template $template, $blockName)
 {
     if ($template->hasBlock($blockName)) {
         return $template;
     }
     // Check parents
     if (false !== ($parent = $template->getParent(array()))) {
         if ($this->findTemplateWithBlock($parent, $blockName) !== false) {
             return $template;
         }
     }
     return false;
 }
开发者ID:norzechowicz,项目名称:datagrid-bundle,代码行数:18,代码来源:DataGridExtension.php

示例6: findTemplateWithBlock

 /**
  * @param \Twig_Template $template
  * @param string         $blockName
  *
  * @return \Twig_Template|bool
  */
 private function findTemplateWithBlock(\Twig_Template $template, $blockName)
 {
     if ($template->hasBlock($blockName)) {
         return $template;
     }
     if (false === ($parent = $template->getParent([]))) {
         return false;
     }
     if (false !== $this->findTemplateWithBlock($parent, $blockName)) {
         return $template;
     }
     return false;
 }
开发者ID:sstok,项目名称:rollerworks-datagrid-twig,代码行数:19,代码来源:DatagridExtension.php


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