本文整理汇总了PHP中Silex\Application::render方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::render方法的具体用法?PHP Application::render怎么用?PHP Application::render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::render方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction(Application $app)
{
$files = $app['em']->getRepository('CMSilex\\Entities\\File')->findAll();
$form = $app['form.factory']->createNamedBuilder(null);
$form->add('file', FileType::class)->add('upload', SubmitType::class)->setAction($app->path('upload'));
return $app->render('media/index.html.twig', ['form' => $form->getForm()->createView(), 'files' => $files, 'heading' => 'Media']);
}
示例2: authenticate
/**
* Authenticats the user
* @param Request Object - contains email and password
*
* @return Nothing
*/
public function authenticate(Application $app, Request $request)
{
$email = $request->get('email');
$password = $app->escape($request->get('password'));
if ($email && $password) {
$user = new User($app);
$user_info = $user->find('user', array('email' => $email, 'password' => md5($password)));
if ($user_info) {
$app['session']->set('user', array('id' => $user_info[0]));
return $app->redirect($request->getBaseUrl() . '/message/tweets');
} else {
return $app->render('index.php.twig', array('error_message' => "Invalid Credentials. Please try again!"));
}
} else {
return $app->render('index.php.twig', array('error_message' => "Valid Email and password are required!"));
}
}
示例3: connect
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->get('/', function (Application $app) {
return $app->render('user_profile.twig');
})->bind('user_profile');
return $controllers;
}
示例4: connect
/**
* @param Application $app
* @return ControllerCollection
*/
public function connect(Application $app)
{
/** @var ControllerCollection $controllers */
$controllers = $app['controllers_factory'];
$controllers->get('/', function (SupervisorApplication $app) {
return $app->render('index.twig', ['supervisors' => $app->supervisor()->getInstances()]);
})->bind('index');
return $controllers;
}
示例5: create
public function create(Application $app, Request $request)
{
$message = $request->get('message');
$user_id = intval($app['session']->get('user')['id']);
if (strlen($message) <= 140) {
$tweet = new Tweet($app);
$tweet->save('tweets', array('tweet' => $message, 'user_id' => $user_id, 'created_at' => date("Y-m-d H:i:s"), 'updated_at' => date("Y-m-d H:i:s")));
$user_tweets = $tweet->find('tweets', array('user_id' => $user_id));
echo var_dump($user_tweets);
} else {
$error_message = "Please limit the message to 140 charecters.";
}
return $app->render('tweets.php.twig', array('tweets' => $user_tweets, 'error_message' => $this->error_message));
}
示例6: connect
/**
* {@inheritdoc}
*/
public function connect(Application $app)
{
$controllers = $app['controllers_factory'];
$controllers->get('/', function (VBeeSiteApplication $app) {
/** @var \VBee\Site\Application\Manager\PersonManagerInterface $personManager */
$personManager = $app['vbee.manager.person'];
$person = new Person();
$person->setEmail('some@test.email');
$person->setGivenName('some');
$person->setFamilyName('test');
$personManager->save($person);
return $app->render('Homepage/index.html.twig', ['person' => $person]);
});
return $controllers;
}
示例7: listEntityAction
public function listEntityAction(CMSEntity $cmsEntity, Application $app, Request $request)
{
$pageNumber = $request->query->has('page') ? $request->query->get('page') : 1;
$limit = $request->query->has('limit') ? $request->query->get('limit') : $cmsEntity->getDefaultPageLimit();
$qb = $app['em']->getRepository($cmsEntity->getClass())->createQueryBuilder('e');
if ($limit && $limit >= 0) {
$qb->setMaxResults($limit);
$qb->setFirstResult(($pageNumber - 1) * $limit);
} else {
$limit = null;
$pageNumber = 1;
}
$paginator = new Paginator($qb);
$entities = [];
foreach ($paginator as $entity) {
$entities[] = $entity;
}
$resultCount = count($paginator);
$totalPages = $limit && $limit <= $resultCount ? ceil($resultCount / $limit) : 1;
return $app->render('admin/list.html.twig', ['columns' => $cmsEntity->getColumns(), 'items' => $entities, 'cmsEntity' => $cmsEntity, 'heading' => ucwords($cmsEntity), 'resultCount' => $resultCount, 'currentPage' => $pageNumber, 'limit' => $limit, 'totalPages' => $totalPages]);
}
示例8: registerAction
public function registerAction(Application $app, Request $request)
{
$builder = $app->form();
$builder->add('email', EmailType::class)->add('password', RepeatedType::class, ['type' => PasswordType::class, 'first_options' => ['label' => 'Password'], 'second_options' => ['label' => 'Repeat Password']])->add('register', SubmitType::class);
$form = $builder->getForm();
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$userInfo = $form->getData();
$newUser = new User();
$password = $app->encodePassword($newUser, $userInfo['password']);
$newUser->setUsername($userInfo['email']);
$newUser->setPassword($password);
$newUser->setEnabled(true);
$newUser->setAccountNonExpired(true);
$newUser->setAccountNonLocked(true);
$newUser->setCredentialsNonExpired(true);
$newUser->setRoles(['ROLE_USER']);
$app['em']->persist($newUser);
$app['em']->flush();
return $app->redirect($app->url('login'));
}
return $app->render('authentication/register.html.twig', ['form' => $form->createView()]);
}
示例9: todoWidgetAction
function todoWidgetAction(Request $request, Application $app)
{
return $app->render('Erp/Dashboard/todo_widget.twig');
}
示例10: render
/**
* @see \Silex\Application\TwigTrait::render
*/
public function render($view, array $parameters = [], Response $response = null)
{
return $this->app->render($view, $parameters, $response);
}
示例11: indexAction
public function indexAction(Application $app)
{
$response = $app->render('index.html.twig');
return $response;
}
示例12: notificationShortcutWidgetAction
function notificationShortcutWidgetAction(Request $request, Application $app)
{
return $app->render('Application/Widget/shortcut_notification.twig');
}
示例13: messagesAction
public function messagesAction(Application $app)
{
$response = new Response();
return $app->render('messages.twig', ['guestbook' => $app['guestbook']->get()], $response->setTtl(10));
}
示例14: home
public function home(Application $app)
{
return $app->render('index.php.twig', array('error_message' => ''));
}
示例15: listOptionsAction
function listOptionsAction(Request $request, Application $app)
{
$options = $app['db']->fetchAll("SELECT * FROM application_options");
return $app->render('Application/Administration/list_options.twig', ['options' => $options]);
}