當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。