Пример #1
0
 public function menuAction(Request $request, Application $app)
 {
     // get reference to our Menu category repository
     $menuCategoryRepository = new MenuCategoryRepository();
     // build arrgs array
     $argsArray = array('categories' => $menuCategoryRepository->getAllMenuCategories());
     //render template
     $templateName = 'menu';
     return $app['twig']->render($templateName . '.html.twig', $argsArray);
 }
Пример #2
0
 /**
  * Action for the menu page of the website. This action makes a new
  * MenuCategoryRepository and gets all the data from the database.
  *
  * Action for route: /menu
  *
  * @param Request $request
  * @param Application $app
  * @return mixed
  */
 public function menuAction(Request $request, Application $app)
 {
     //check if username is stored in session
     $username = getAuthenticatedUsername($app);
     // get reference to our Menu category repository
     $menuCategoryRepository = new MenuCategoryRepository();
     // build args array
     $argsArray = array('username' => $username, 'categories' => $menuCategoryRepository->getAllMenuCategories());
     //render template
     $templateName = 'menu';
     return $app['twig']->render($templateName . '.html.twig', $argsArray);
 }
 public function testGetAllMenuCategories()
 {
     // Arrange
     $repository = new MenuCategoryRepository();
     $category = new MenuCategory(1);
     $expectedResult = new MenuCategory(2);
     $expectedResult->setMenuCategoryTitle("Salads");
     $expectedResult->setMenuCategoryImage("salad.png");
     $expectedResult->setMenuCategorySummary("A healthy menu item that can be enjoyed in any season and has the benefit of low calories and a good source of energy. Our range of salads are carefully prepared from fresh leaves on the day it is served.");
     // Act
     $repository->getAllMenuCategories();
     $result = $repository->getOneMenuCategoryItem(2);
     // Assert
     $this->assertEquals($result, $expectedResult);
 }
Пример #4
0
 /**
  * Action for changing a product's properties. This action handles the category
  * selection part of the process
  *
  * Action for route: /adminChangeProductSelectCategory
  *
  * @param Request $request
  * @param Application $app
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function changeProductSelectCategoryAction(Request $request, Application $app)
 {
     // test if 'username' stored in session ...
     $username = getAuthenticatedUserName($app);
     // check we are authenticated --------
     $isAuthenticated = null != $username;
     if (!$isAuthenticated) {
         // not authenticated, so redirect to LOGIN page
         return $app->redirect('/login');
     }
     $menuCategoryRepository = new MenuCategoryRepository();
     // store username into args array
     $argsArray = array('title' => "Admin Change Products - pick a category", 'categories' => $menuCategoryRepository->getAllMenuCategories(), 'username' => $username);
     // render (draw) template
     // ------------
     $templateName = 'admin/changeProductSelectCategory';
     return $app['twig']->render($templateName . '.html.twig', $argsArray);
 }