public function deleteAction(Request $request)
 {
     // Check user is logged in
     $this->loggedInCheck();
     // Get post delete items
     $deleteItems = $request->get('deleteItems');
     $items = explode(',', $deleteItems);
     // Delete required items
     foreach ($items as $item) {
         $this->getService('admin.userlevels.storage')->deleteById($item);
     }
     // Inform the user
     $this->setFlash('success', 'Selected items have been deleted successfully');
     return $this->redirectToRoute('AdminModule_User_Levels');
 }
Example #2
0
 /**
  * Run the application and send the response.
  *
  * @param RequestInterface|null $request
  * @param ResponseInterface|null $response
  * @return Response
  * @throws \Exception
  */
 public function run(RequestInterface $request = null, ResponseInterface $response = null)
 {
     if (false === $this->booted) {
         $this->boot();
     }
     $request = $request ?: HttpRequest::createFromGlobals();
     $response = $response ?: new Response();
     $response = $this->dispatch($request, $response);
     $response->send();
     return $response;
 }
Example #3
0
 /**
  * Create and return a request instance.
  *
  * @param ServiceLocatorInterface $serviceLocator
  *
  * @return \PPI\Framework\Http\Request
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     return Request::createFromGlobals();
 }
Example #4
0
 /**
  * Run the application and send the response.
  *
  * @param HttpRequest|null  $request
  * @param HttpResponse|null $response
  *
  * @throws \Exception
  *
  * @return HttpResponse
  */
 public function run(HttpRequest $request = null, HttpResponse $response = null)
 {
     if (false === $this->booted) {
         $this->boot();
     }
     if (null === $request) {
         $request = HttpRequest::createFromGlobals();
     }
     if (null === $response) {
         $response = new HttpResponse();
     }
     $response = $this->dispatch($request, $response);
     $response->send();
     return $response;
 }
Example #5
0
 public function testDispatch()
 {
     $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__));
     $this->controllerUnderTest = [new ControllerForAppTest(), 'indexAction'];
     $app = $this->setupAppMocks($app, $this->setupMockRouter(), $this->setupMockControllerResolver());
     $request = HttpRequest::createFromGlobals();
     $response = new HttpResponse();
     $response = $app->dispatch($request, $response);
     $this->assertInstanceOf('\\Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertEquals($response->getContent(), 'Working Response From Controller Index Action');
 }
Example #6
0
 /**
  * Run the application and send the response.
  *
  * @param HttpRequest|null  $request
  * @param HttpResponse|null $response
  *
  * @throws \Exception
  *
  * @return HttpResponse
  */
 public function run(HttpRequest $request = null, HttpResponse $response = null)
 {
     if (false === $this->booted) {
         $this->boot();
     }
     if (null === $request) {
         $request = HttpRequest::createFromGlobals();
     }
     if (null === $response) {
         $response = new HttpResponse();
     }
     // Create a copy of request, as it's by-ref passed into $this->dispatch() and gets modified.
     $cleanRequest = clone $request;
     try {
         $response = $this->dispatch($request, $response);
     } catch (ResourceNotFoundException $e) {
         if ($this->symfonyKernel === null) {
             throw $e;
         }
         $response = $this->symfonyKernel->handle($cleanRequest);
     }
     $response->send();
     return $response;
 }
Example #7
0
 public function changepasswordsaveAction(Request $request)
 {
     // Check user is logged in
     $this->loggedInCheck();
     // Get post variables
     $password = $request->get('userPassword');
     $user_id = $request->get('userId');
     // Get config
     $config = $this->getConfig();
     // Get user storage from AuthModule
     $userStorage = $this->getService('auth.user.storage');
     // Get security helper
     $security = $this->getService('auth.security');
     // Get user with user id
     $user = $userStorage->getById($user_id);
     // Validate user id
     if ($user === false) {
         throw new \Exception('No user found using user id: ' . $user_id);
     }
     // Validate password
     if ($password == '') {
         $rand_password = $security->generateStrongPassword();
         $this->setFlash('danger', 'Password field was blank please re-evaluate your input and try again!');
         return $this->render('AdminModule:users:changepassword.html.php', compact('user', 'rand_password'));
     }
     // Get new encrypted password
     $encPassword = $security->saltPass($user->getSalt(), $config['authSalt'], $password);
     // Update user password
     $userStorage->updatePassword($user->getId(), $encPassword);
     $this->setFlash('success', 'Password changed successfully');
     return $this->redirectToRoute('AdminModule_Users');
 }
Example #8
0
 public function testDispatch()
 {
     $app = new AppForDispatchTest(array('environment' => 'test', 'debug' => true, 'rootDir' => __DIR__));
     $mockRouter = $this->getMockBuilder('PPI\\Framework\\Router\\ChainRouter')->disableOriginalConstructor()->getMock();
     $mockRouter->expects($this->once())->method('warmUp');
     $mockRouter->expects($this->once())->method('matchRequest')->willReturn(array('_controller' => 'TestController'));
     $mockControllerResolver = $this->getMockBuilder('PPI\\Framework\\Module\\Controller\\ControllerResolver')->disableOriginalConstructor()->getMock();
     $mockControllerResolver->expects($this->once())->method('getController')->willReturnCallback(function () {
         return function () {
             return new Response('Working Response');
         };
     });
     $mockControllerResolver->expects($this->once())->method('getArguments')->willReturn(array());
     $sm = new ServiceManager();
     $sm->setAllowOverride(true);
     $sm->set('Router', $mockRouter);
     $sm->set('ControllerResolver', $mockControllerResolver);
     $app->setServiceManager($sm);
     $request = HttpRequest::createFromGlobals();
     $response = new HttpResponse();
     $response = $app->dispatch($request, $response);
     $this->assertInstanceOf('\\Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertEquals($response->getContent(), 'Working Response');
 }