Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- self.sendData = function(url, data){
- var promise = $q.defer();
- console.log("Dentro de senDAta!!!");
- var config = {
- headers : {
- "Accept" : "applicationjson",
- "Content-Type" : "applicationjson"
- },
- resposeType : "json"
- };
- $http.post(url, data, config).success(function(response, status, headers, config){
- console.log("dentro de success!!!");
- promise.resolve(response);
- }).error(function(data){
- //Error de sistemas
- console.log("Error en sendData: " + data);
- });
- return promise.promise;
- };
- return [
- //...
- 'view_manager' => [
- //...
- 'strategies' => [
- 'ViewJsonStrategy',
- ],
- ],
- ];
- public function loginAction(){
- $request = $this->getRequest();
- $log = new FileLogWriter();
- $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": Dentro de loginAction()");
- if ($this->getRequest()->isXmlHttpRequest() === true){
- $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": Llamada hecha por Ajax");
- }else{
- $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": Llamada no hecha por ajax");
- }
- $params = json_decode(file_get_contents('php://input'),true);
- $email = $params["email"];
- $password = $params["password"];
- $log->writeLog(get_class($this) . "::" . __FUNCTION__ . ": email: " . $email . " password: " . $password);
- $user = new User($email);
- return new JsonModel([
- "result" => 0
- ]);
- }
- return [
- //...
- 'view_manager' => [
- //...
- 'strategies' => [
- 'ViewJsonStrategy',
- ],
- ],
- ];
- public function onBootstrap(MvcEvent $e)
- {
- // Register a "render" event, at high priority (so it executes prior
- // to the view attempting to render)
- $app = $e->getApplication();
- $app->getEventManager()->attach('render', [$this, 'registerJsonStrategy'], 100);
- }
- public function registerJsonStrategy(MvcEvent $e)
- {
- $app = $e->getTarget();
- $locator = $app->getServiceManager();
- $view = $locator->get('ZendViewView');
- $jsonStrategy = $locator->get('ViewJsonStrategy');
- // Attach strategy, which is a listener aggregate, at high priority
- $jsonStrategy->attach($view->getEventManager(), 100);
- }
- $view->getEventManager()->attach($jsonStrategy, 100);
- $view->getEventManager()->attach($jsonStrategy, 100);
- $jsonStrategy->attach($view->getEventManager(), 100);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement