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


PHP Twig_Environment::render方法代码示例

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


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

示例1: validate

 /**
  * {@inheritdoc}
  */
 public function validate($emailTemplate, Constraint $constraint)
 {
     /** @var EmailTemplate $emailTemplate */
     /** @var VariablesConstraint $constraint */
     $fieldsToValidate = array('subject' => $emailTemplate->getSubject(), 'content' => $emailTemplate->getContent());
     foreach ($emailTemplate->getTranslations() as $trans) {
         if (in_array($trans->getField(), array('subject', 'content'))) {
             $fieldsToValidate[$trans->getLocale() . '.' . $trans->getField()] = $trans->getContent();
         }
     }
     $relatedEntity = false;
     if (class_exists($emailTemplate->getEntityName())) {
         $className = $emailTemplate->getEntityName();
         $relatedEntity = new $className();
     }
     $errors = array();
     foreach ($fieldsToValidate as $field => $value) {
         try {
             $this->twig->render($value, array('entity' => $relatedEntity, 'user' => $this->getUser()));
         } catch (\Exception $e) {
             $errors[$field] = true;
         }
     }
     if (!empty($errors)) {
         $this->context->addViolation($constraint->message);
     }
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:30,代码来源:VariablesValidator.php

示例2: execute

 /**
  * Execute Command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $email = $this->twig->render('test.twig');
     $message = $this->mailer->createMessage()->setSubject('PHP RFC Digestor Test Email')->setFrom('notifier@php-rfc-digestor.com')->setTo($input->getArgument('email'))->setBody($email, 'text/html');
     $this->mailer->send($message);
     $output->writeln(sprintf('<info>Email sent to %s</info>', $input->getArgument('email')));
 }
开发者ID:shakyShane,项目名称:php-rfc-digestor,代码行数:13,代码来源:Email.php

示例3: summernoteInit

 /**
  * @return string
  */
 public function summernoteInit()
 {
     $template = $this->parameters['init_template'];
     $options = [];
     $options['fontname'] = count($this->parameters['fontname']) > 0 ? $this->prepareArrayParameter('fontname') : $this->getDefaultFontname();
     $options['fontnocheck'] = count($this->parameters['fontnocheck'] > 0) ? $this->prepareArrayParameter('fontnocheck') : null;
     $options['language'] = isset($this->parameters['language']) ? $this->parameters['language'] : null;
     $options['plugins'] = isset($this->parameters['plugins']) ? $this->parameters['plugins'] : null;
     $options['selector'] = $this->parameters['selector'];
     $options['width'] = $this->parameters['width'];
     $options['height'] = $this->parameters['height'];
     $options['include_jquery'] = $this->parameters['include_jquery'];
     $options['include_bootstrap'] = $this->parameters['include_bootstrap'];
     $options['include_fontawesome'] = $this->parameters['include_fontawesome'];
     $options['fontawesome_path'] = $this->parameters['fontawesome_path'];
     $options['bootstrap_css_path'] = $this->parameters['bootstrap_css_path'];
     $options['bootstrap_js_path'] = $this->parameters['bootstrap_js_path'];
     $options['jquery_path'] = $this->parameters['jquery_path'];
     $options['summernote_css_path'] = $this->parameters['summernote_css_path'];
     $options['summernote_js_path'] = $this->parameters['summernote_js_path'];
     $options['jquery_version'] = $this->parameters['jquery_version'];
     $options['toolbar'] = $this->prepareToolbar();
     $base_path = !isset($this->parameters['base_path']) ? 'bundles/fmsummernote/Jquery' . $options['jquery_version'] . '.x/' : $this->parameters['base_path'];
     return $this->twig->render($template, ['sn' => $options, 'base_path' => $base_path]);
 }
开发者ID:helios-ag,项目名称:FMSummernoteBundle,代码行数:28,代码来源:FMSummernoteExtension.php

示例4: parse

 public function parse($buffer, $context = array())
 {
     /** @var \Twig_Loader_Array $loader */
     $loader = $this->twigEnvironment->getLoader();
     $loader->setTemplate('__TEMPLATE__', $buffer);
     return $this->twigEnvironment->render('__TEMPLATE__', $context);
 }
开发者ID:Ainschy,项目名称:contao-message,代码行数:7,代码来源:TagReplacementService.php

示例5: run

 /**
  * @param Activity $activity
  *
  * @return Result
  */
 public function run(Activity $activity)
 {
     $challenge = $activity->getChallengeObject();
     $worker = $this->getWorker($challenge->getExecutionMode());
     // 1) write all of the files        (different for contexts)
     // 2) call setupContext()           (different for contexts)
     // 3) call grade() and use results  (different for contexts)
     $filesToWrite = $this->getFilesToCreate($activity);
     $initialExecutionResult = new CodingExecutionResult($filesToWrite);
     // serialize this, so we can easily fetch the input files
     $filesToWrite['executionResult.cache'] = serialize($initialExecutionResult);
     // write the challenge class name
     $filesToWrite['ChallengeClass.php'] = $activity->getChallengeClassContents();
     // write our executor.php and execute that
     $executionCode = $this->twig->render('code_executor.php.twig', array('workerClass' => get_class($worker), 'projectPath' => $this->projectRootDir, 'challengeFilename' => 'ChallengeClass.php', 'challengeClassName' => $activity->getChallengeClassName(), 'entryPointFilename' => $challenge->getFileBuilder()->getEntryPointFilename()));
     $filesToWrite['execution.php'] = $executionCode;
     $codeExecutor = new CodeExecutor($filesToWrite, 'execution.php');
     $executionResult = $codeExecutor->executePhpProcess();
     $result = new Result($activity);
     // clean things up just in case - but the worker should take care of this
     $result->setLanguageError(self::cleanError($executionResult->getLanguageError(), $executionResult->getCodeDirectory()));
     $result->setGradingError($executionResult->getGradingError());
     $result->setOutput($executionResult->getOutput());
     return $result;
 }
开发者ID:knpuniversity,项目名称:activity-runner,代码行数:30,代码来源:ActivityRunner.php

示例6: getLogs

 public function getLogs($entity)
 {
     if (!is_object($entity)) {
         return '';
     }
     return $this->twig->render($this->template, array('logEntities' => $this->logsFromEntity($entity)));
 }
开发者ID:hasantayyar,项目名称:ojs,代码行数:7,代码来源:HistoryExtension.php

示例7: replace

 public function replace($zpl, array $params = [])
 {
     if (empty($zpl)) {
         return '';
     }
     return $this->twig->render($zpl, $params);
 }
开发者ID:kofel,项目名称:gutenberg,代码行数:7,代码来源:VariableReplacer.php

示例8: renderTwig

 protected function renderTwig($template, $vars)
 {
     $vars['alerts'] = $this->getAlerts();
     if (!empty($this->post)) {
         $vars['post'] = $this->post;
     } else {
         if (!empty($_SESSION['post'])) {
             $vars['post'] = $_SESSION['post'];
         }
     }
     if (!empty($this->get)) {
         $vars['get'] = $this->get;
     } else {
         if (!empty($_SESSION['get'])) {
             $vars['get'] = $_SESSION['get'];
         }
     }
     if (!empty($_SESSION['user'])) {
         $vars['curUser'] = $_SESSION['user'];
     }
     echo $this->twig->render($template, $vars);
     $this->resetAlerts();
     unset($_SESSION['post']);
     unset($_SESSION['get']);
 }
开发者ID:Jimgitsit,项目名称:basic-mvc,代码行数:25,代码来源:BasePage.php

示例9: fetch

 /**
  * @see IRenderEngine::fetch()
  */
 function fetch($template)
 {
     if (strpos('.', $template) === false) {
         $template .= '.html';
     }
     return $this->twig->render($template, $this->assignments);
 }
开发者ID:hpazevedo,项目名称:Teste-BDR,代码行数:10,代码来源:TwigRenderEngine.php

示例10: renderFieldDisplay

 /**
  * @param \Twig_Environment $environment
  * @param FieldableEntity $entity
  * @param string $field
  *
  * @return string
  * @internal param \Twig_Environment $environment
  */
 public function renderFieldDisplay(\Twig_Environment $environment, FieldableEntity $entity, $field)
 {
     $class = get_class($entity);
     $displayMapping = $this->displayManager->getEntityConfig($class);
     $fieldSettings = $this->fieldManager->getEntityFieldMapping($class);
     $html = '';
     if ($displayMapping['options']['fields'][$field]) {
         $displayFieldSettings = $displayMapping['options']['fields'][$field] + ['type' => null, 'label' => true, 'label_inline' => false, 'options' => []];
         $display = $this->displayManager->getDisplayDefinition($displayFieldSettings['type']);
         $fieldEntity = call_user_func([$entity, 'get' . $field]);
         $fieldDisplayOptions = $displayFieldSettings['options'] ?: [];
         $templateOptions = ['entity' => $fieldEntity, 'field_settings' => $fieldSettings, 'field_name' => $field, 'label' => is_string($displayFieldSettings['label']) ?: ($displayFieldSettings['label'] ? $field : false), 'label_inline' => $displayFieldSettings['label_inline']];
         if ($fieldSettings[$field]['options']['limit'] > 1) {
             $subHtml = '';
             $subTemplateOptions = $templateOptions;
             $subTemplateOptions['label'] = false;
             foreach ($fieldEntity as $fieldEntityItem) {
                 $subHtml .= $environment->render($display->getTemplate(), $subTemplateOptions + $display->getTemplateOptions($fieldEntityItem, $fieldDisplayOptions));
             }
             $templateOptions['rows'] = $subHtml;
             $html = $environment->render($display->getListTemplate(), $templateOptions + $display->getListTemplateOptions($fieldEntity, $fieldDisplayOptions));
         } else {
             $html = $environment->render($display->getTemplate(), $templateOptions + $display->getTemplateOptions($fieldEntity, $fieldDisplayOptions));
         }
     }
     return $html;
 }
开发者ID:gravity-cms,项目名称:cms-bundle,代码行数:35,代码来源:DisplayExtension.php

示例11: process

 /**
  * {@inheritDoc}
  */
 public function process($layoutSrc, Response $response, array $placeResponses)
 {
     if (!$this->twig->hasExtension('supraPage')) {
         throw new \UnexpectedValueException('Missing for Supra Page extension.');
     }
     $response->setContent($this->twig->render($layoutSrc, array('responses' => $placeResponses)));
 }
开发者ID:sitesupra,项目名称:sitesupra,代码行数:10,代码来源:TwigProcessor.php

示例12: summernoteInit

 /**
  * @return string
  */
 public function summernoteInit()
 {
     $template = $this->parameters['init_template'];
     $options = [];
     $options['language'] = isset($this->parameters['language']) ? $this->parameters['language'] : null;
     $options['plugins'] = isset($this->parameters['plugins']) ? $this->parameters['plugins'] : null;
     $options['selector'] = $this->parameters['selector'];
     $options['width'] = $this->parameters['width'];
     $options['height'] = $this->parameters['height'];
     $options['include_jquery'] = $this->parameters['include_jquery'];
     $options['include_bootstrap'] = $this->parameters['include_bootstrap'];
     $options['include_fontawesome'] = $this->parameters['include_fontawesome'];
     $options['fontawesome_path'] = $this->parameters['fontawesome_path'];
     $options['bootstrap_css_path'] = $this->parameters['bootstrap_css_path'];
     $options['bootstrap_js_path'] = $this->parameters['bootstrap_js_path'];
     $options['jquery_path'] = $this->parameters['jquery_path'];
     $options['summernote_css_path'] = $this->parameters['summernote_css_path'];
     $options['summernote_js_path'] = $this->parameters['summernote_js_path'];
     $options['upload_images'] = $this->parameters['upload_images'];
     $options['image_upload_route'] = $this->parameters['image_upload_route'];
     $options['max_upload_size'] = $this->parameters['max_upload_size'];
     $options['toolbar'] = $this->prepareToolbar();
     $basePath = !isset($this->parameters['base_path']) ? 'bundles/adnsummernote/' : $this->parameters['base_path'];
     return $this->twig->render($template, ['sn' => $options, 'base_path' => $basePath]);
 }
开发者ID:adnedelcu,项目名称:SummernoteBundle,代码行数:28,代码来源:ADNSummernoteExtension.php

示例13: render

 /**
  * {@inheritdoc}
  */
 public function render(array $context, $template = null)
 {
     if (null === $template) {
         $template = $this->template;
     }
     return $this->twig->render($template, $context);
 }
开发者ID:silvestra,项目名称:silvestra,代码行数:10,代码来源:AlertHelper.php

示例14: indexAction

 public function indexAction(Request $request)
 {
     $response = new Response();
     $response->setPrivate();
     $response->setContent($this->twig->render('www/Index.twig', array()));
     return $response;
 }
开发者ID:myurasov,项目名称:spa-bootstrap,代码行数:7,代码来源:IndexController.php

示例15: getBacktraceView

 public function getBacktraceView(array $backtrace)
 {
     $result = [];
     $appRoot = realpath($this->appRoot . '/../');
     foreach ($backtrace as $k => $v) {
         $item = [];
         if (isset($v['file'])) {
             $item['location'] = str_replace($appRoot, '', $v['file']) . '(' . $v['line'] . ')';
             if (strpos($item['location'], '/vendor') === 0) {
                 $item['hidden'] = true;
                 foreach ($this->excludes as $exclude) {
                     if (preg_match('#^/vendor/' . $exclude . '#', $item['location'])) {
                         $item['hidden'] = false;
                         break;
                     }
                 }
             } else {
                 $item['hidden'] = false;
             }
         } else {
             $item['location'] = '[internal function]';
             $item['hidden'] = true;
         }
         if (isset($v['type'])) {
             $item['element'] = $v['class'] . $v['type'] . $v['function'] . '()';
         } else {
             $item['element'] = $v['function'] . '()';
         }
         $result[] = $item;
     }
     return $this->environment->render('AkhristenkoDoctrineStacktraceBundle:Backtrace:view.html.twig', ['backtrace' => $backtrace, 'result' => $result]);
 }
开发者ID:akhristenko,项目名称:doctrine-stacktrace-bundle,代码行数:32,代码来源:BacktraceExtension.php


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