Advertisement
Guest User

Untitled

a guest
Sep 17th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. self.sendData = function(url, data){
  2. var promise = $q.defer();
  3. console.log("Dentro de senDAta!!!");
  4. var config = {
  5. headers : {
  6. "Accept" : "applicationjson",
  7. "Content-Type" : "applicationjson"
  8. },
  9. resposeType : "json"
  10. };
  11. $http.post(url, data, config).success(function(response, status, headers, config){
  12. console.log("dentro de success!!!");
  13. promise.resolve(response);
  14. }).error(function(data){
  15. //Error de sistemas
  16. console.log("Error en sendData: " + data);
  17. });
  18. return promise.promise;
  19. };
  20.  
  21. return [
  22. //...
  23.  
  24. 'view_manager' => [
  25. //...
  26.  
  27. 'strategies' => [
  28. 'ViewJsonStrategy',
  29. ],
  30. ],
  31. ];
  32.  
  33. public function loginAction(){
  34. $request = $this->getRequest();
  35. $log = new FileLogWriter();
  36. $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": Dentro de loginAction()");
  37. if ($this->getRequest()->isXmlHttpRequest() === true){
  38. $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": Llamada hecha por Ajax");
  39. }else{
  40. $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": Llamada no hecha por ajax");
  41. }
  42. $params = json_decode(file_get_contents('php://input'),true);
  43. $email = $params["email"];
  44. $password = $params["password"];
  45.  
  46. $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": email: " . $email . " password: " . $password);
  47. $user = new User($email);
  48. return new JsonModel([
  49. "result" => 0
  50. ]);
  51. }
  52.  
  53. return [
  54. //...
  55.  
  56. 'view_manager' => [
  57. //...
  58.  
  59. 'strategies' => [
  60. 'ViewJsonStrategy',
  61. ],
  62. ],
  63. ];
  64.  
  65. public function onBootstrap(MvcEvent $e)
  66. {
  67. // Register a "render" event, at high priority (so it executes prior
  68. // to the view attempting to render)
  69. $app = $e->getApplication();
  70. $app->getEventManager()->attach('render', [$this, 'registerJsonStrategy'], 100);
  71. }
  72.  
  73. public function registerJsonStrategy(MvcEvent $e)
  74. {
  75. $app = $e->getTarget();
  76. $locator = $app->getServiceManager();
  77. $view = $locator->get('ZendViewView');
  78. $jsonStrategy = $locator->get('ViewJsonStrategy');
  79.  
  80. // Attach strategy, which is a listener aggregate, at high priority
  81. $jsonStrategy->attach($view->getEventManager(), 100);
  82. }
  83.  
  84. $view->getEventManager()->attach($jsonStrategy, 100);
  85.  
  86. $view->getEventManager()->attach($jsonStrategy, 100);
  87.  
  88. $jsonStrategy->attach($view->getEventManager(), 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement