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


PHP Application::renderView方法代码示例

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


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

示例1: register

 public function register(Application $app)
 {
     $app->get('/', function () use($app) {
         return $app->renderView('index.html.twig', array('settings' => $app['gearmanui.settings']));
     });
     $app->get('/status', function () use($app) {
         return $app->renderView('status.html.twig');
     });
     $app->get('/workers', function () use($app) {
         return $app->renderView('workers.html.twig');
     });
     $app->get('/servers', function () use($app) {
         return $app->renderView('servers.html.twig');
     });
     $app->get('/info', function (Request $request) use($app) {
         $info = $app['gearman.serverInfo']->getServersInfo();
         return new JsonResponse($info);
         // return $app->renderView('gearman.json.twig');
     });
 }
开发者ID:jujhars13,项目名称:gearman-ui.docker,代码行数:20,代码来源:ControllerProvider.php

示例2: displayEmailAction

 public function displayEmailAction(Application $app, Request $request, $email, $ext)
 {
     $dns = $this->options['dns'];
     $vars = ['login_route' => $request->get('_login_route'), 'register_confirm_route' => $request->get('_register_confirm_route'), 'register_route' => $request->get('_register_route'), 'recover_password_confirm_route' => $request->get('_recover_password_confirm_route'), 'from' => 'no-reply@sup.net', 'to' => 'johndoe@whatever.com'];
     switch ($email) {
         case 'require_email_verification':
             $vars['subject'] = $app['translator']->trans($dns . 'require_email_verification.subject');
             $vars['token'] = 'xxxTOKENxxx';
             break;
         case 'email_verification':
             $vars['subject'] = $app['translator']->trans($dns . 'email_verification.subject');
             $vars['token'] = 'xxxTOKENxxx';
             break;
         case 'recover_password':
             $vars['subject'] = $app['translator']->trans($dns . 'email_recover_password.subject');
             $vars['token'] = 'xxxTOKENxxx';
             break;
         default:
             $app->abort(404, "{$email} not found");
     }
     $vars = call_user_func($app[$dns . 'twig_vars_injector'], 'email:' . $email, $request, $vars);
     return $app->renderView($this->options['ns'] . "/email/{$email}.{$ext}.twig", $vars);
 }
开发者ID:quazardous,项目名称:silex-user-pack,代码行数:23,代码来源:DebugController.php

示例3: changePasswordAction

 public function changePasswordAction(Application $app, Request $request)
 {
     $dns = $this->options['dns'];
     $firewall = $request->get('_firewall');
     $changePasswordException = $request->getSession()->get($dns . 'change_password_exception', []);
     $changePasswordException += ['field_errors' => [], 'message' => null];
     $vars = ['title' => 'User Pack Change Password', 'error' => $changePasswordException['message']];
     $userChangePasswordForm = $app->namedForm('user_change_password')->add('old_password', PasswordType::class, ['label' => $dns . 'change_password.labels.old_password'])->add('password', PasswordType::class, ['label' => $dns . 'change_password.labels.password'])->add('confirm_password', PasswordType::class, ['label' => $dns . 'change_password.labels.confirm_password'])->add('submit', SubmitType::class, ['label' => $dns . 'change_password.labels.submit'])->getForm();
     $userChangePasswordForm->handleRequest($request);
     if ($userChangePasswordForm->isSubmitted()) {
         if ($userChangePasswordForm->isValid()) {
             $data = $userChangePasswordForm->getData();
             /** @var \Symfony\Component\Security\Core\User\User $user */
             $user = $app['user'];
             $dbUser = $app[$dns . 'user_loader']($user->getUsername(), false);
             if (!$app[$dns . 'password_validator']($dbUser->getPassword(), $data['old_password'])) {
                 $request->getSession()->getFlashBag()->add('message', $app['translator']->trans($dns . 'change_password.messages.bad_old_password'));
                 $request->getSession()->remove($dns . 'change_password_exception');
                 return $app->redirect($request->getUri());
             }
             unset($data['old_password']);
             $constraints = [];
             $constraints['password'] = new Constraints\Length(['min' => 8, 'minMessage' => $dns . 'change_password.validators.password.length.min', 'max' => 16, 'maxMessage' => $dns . 'change_password.validators.password.length.max']);
             $constraints['confirm_password'] = new Constraints\EqualTo(['value' => $data['password'], 'message' => $dns . 'change_password.validators.confirm_password.equal_to.password']);
             $constraints = new Constraints\Collection($constraints);
             $violations = $app['validator']->validate($data, $constraints);
             if (count($violations)) {
                 $fieldErrors = [];
                 foreach ($violations as $violation) {
                     /** @var \Symfony\Component\Validator\ConstraintViolation $violation */
                     $field = $violation->getPropertyPath();
                     $field = trim($field, '[]');
                     if (!isset($fieldErrors[$field])) {
                         $fieldErrors[$field] = [];
                     }
                     $fieldErrors[$field][] = $violation->getMessage();
                 }
                 $request->getSession()->set($dns . 'change_password_exception', ['message' => $app['translator']->trans($dns . 'change_password.errors.validation', [], 'errors'), 'field_errors' => $fieldErrors]);
             } else {
                 $dbUser->setPassword($app[$dns . 'password_encoder']($data['password']));
                 $app['orm.em']->flush();
                 $request->getSession()->getFlashBag()->add('message', $app['translator']->trans($dns . 'change_password.messages.password_changed'));
                 $request->getSession()->remove($dns . 'change_password_exception');
             }
         }
     }
     if ($request->isMethod('POST')) {
         return $app->redirect($request->getUri());
     }
     foreach ($changePasswordException['field_errors'] as $field => $errors) {
         if ($userChangePasswordForm->has($field)) {
             foreach ($errors as $error) {
                 $userChangePasswordForm->get($field)->addError(new FormError($error));
             }
         }
     }
     $vars['user_change_password_form'] = $userChangePasswordForm->createView();
     foreach ($this->publicRoutes as $route) {
         $vars[$route] = $request->get($route);
     }
     $vars = call_user_func($app[$dns . 'twig_vars_injector'], 'front:' . __METHOD__, $request, $vars);
     return $app->renderView($this->options['ns'] . "/front/change_password.html.twig", $vars);
 }
开发者ID:quazardous,项目名称:silex-user-pack,代码行数:63,代码来源:FrontController.php


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