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']); }
/** * 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!")); } }
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; }
/** * @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; }
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)); }
/** * {@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('*****@*****.**'); $person->setGivenName('some'); $person->setFamilyName('test'); $personManager->save($person); return $app->render('Homepage/index.html.twig', ['person' => $person]); }); return $controllers; }
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]); }
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()]); }
function todoWidgetAction(Request $request, Application $app) { return $app->render('Erp/Dashboard/todo_widget.twig'); }
/** * @see \Silex\Application\TwigTrait::render */ public function render($view, array $parameters = [], Response $response = null) { return $this->app->render($view, $parameters, $response); }
public function indexAction(Application $app) { $response = $app->render('index.html.twig'); return $response; }
function notificationShortcutWidgetAction(Request $request, Application $app) { return $app->render('Application/Widget/shortcut_notification.twig'); }
public function messagesAction(Application $app) { $response = new Response(); return $app->render('messages.twig', ['guestbook' => $app['guestbook']->get()], $response->setTtl(10)); }
public function home(Application $app) { return $app->render('index.php.twig', array('error_message' => '')); }
function listOptionsAction(Request $request, Application $app) { $options = $app['db']->fetchAll("SELECT * FROM application_options"); return $app->render('Application/Administration/list_options.twig', ['options' => $options]); }
function dashboardAction(Request $request, Application $app) { return $app->render('Application/Layout/dashboard.twig', ['dashboard' => $app['layout']->getHTMLDashboard(), 'title' => 'Dashboard']); }
function settingsAction(Request $request, Application $app) { return $app->render('Application/User/settings.twig', []); }
function indexAction(Request $request, Application $app) { //$app->register(new \Silex\Provider\ValidatorServiceProvider()); $users = $app['db']->fetchAll("SELECT * FROM application_users ORDER BY first_name ASC"); return $app->render('Application/directory.twig', ['title' => 'Clients', 'breadcrumb' => ['#1' => 'Administration', '#2' => 'Clients'], 'items' => $users]); }
public function getPostAction(Post $post, Application $app, Request $request) { return $app->render('@theme/page.html.twig', ['page' => $post]); }