public function statusAction()
    {
        $applicationId = $this->params('id');
        /* @var \Applications\Repository\Application $repository */
        $repository    = $this->repositories->get('Applications/Application');
        /* @var Application $application */
        $application   = $repository->find($applicationId);

        /* @var Request $request */
        $request = $this->getRequest();

        if (!$application) {
            throw new \InvalidArgumentException('Could not find application.');
        }
        
        $this->acl($application, 'change');
        
        $jsonFormat    = 'json' == $this->params()->fromQuery('format');
        $status        = $this->params('status', Status::CONFIRMED);
        $settings = $this->settings();
        
        if (in_array($status, array(Status::INCOMING))) {
            $application->changeStatus($status);
            if ($request->isXmlHttpRequest()) {
                $response = $this->getResponse();
                $response->setContent('ok');
                return $response;
            }
            if ($jsonFormat) {
                return array(
                    'status' => 'success',
                );
            }
            return $this->redirect()->toRoute('lang/applications/detail', array(), true);
        }

        $events = $this->appEvents;

        /* @var ApplicationEvent $event */
        $event = $events->getEvent(
            ApplicationEvent::EVENT_APPLICATION_STATUS_CHANGE,
                                   $this,
                                   [
                                       'application' => $application,
                                       'status' => $status,
                                       'user' => $this->auth()->getUser(),
                                   ]
        );
        
        $event->setIsPostRequest($request->isPost());
        $event->setPostData($request->getPost());
        $events->trigger($event->getName(), $event);

        $params = $event->getFormData();


        if ($request->isPost()) {
            if ($jsonFormat) {
                return array(
                    'status' => 'success',
                );
            }
            $this->notification()->success($event->getNotification());
            return $this->redirect()->toRoute('lang/applications/detail', array(), true);
        }

        if ($jsonFormat) {
            return $params;
        }

        /* @var \Applications\Form\Mail $form */
        $form = $this->forms->get('Applications/Mail');
        $form->populateValues($params);



        $recipient = $params['to'];

        return [
            'recipient' => $recipient,
            'form' => $form
        ];
    }
public function statusAction()
    {
        $applicationId = $this->params('id');
        /* @var \Applications\Repository\Application $repository */
        $repository    = $this->repositories->get('Applications/Application');
        /* @var Application $application */
        $application   = $repository->find($applicationId);

        /* @var Request $request */
        $request = $this->getRequest();

        if (!$application) {
            throw new \InvalidArgumentException('Could not find application.');
        }
        
        $this->acl($application, 'change');
        
        $jsonFormat    = 'json' == $this->params()->fromQuery('format');
        $status        = $this->params('status', Status::CONFIRMED);
        $settings = $this->settings();
        
        if (in_array($status, array(Status::INCOMING))) {
            $application->changeStatus($status);
            if ($request->isXmlHttpRequest()) {
                $response = $this->getResponse();
                $response->setContent('ok');
                return $response;
            }
            if ($jsonFormat) {
                return array(
                    'status' => 'success',
                );
            }
            return $this->redirect()->toRoute('lang/applications/detail', array(), true);
        }

        $events = $this->appEvents;

        /* @var ApplicationEvent $event */
        $event = $events->getEvent(
            ApplicationEvent::EVENT_APPLICATION_STATUS_CHANGE,
                                   $this,
                                   [
                                       'application' => $application,
                                       'status' => $status,
                                       'user' => $this->auth()->getUser(),
                                   ]
        );
        
        $event->setIsPostRequest($request->isPost());
        $event->setPostData($request->getPost());
        $events->trigger($event->getName(), $event);

        $params = $event->getFormData();


        if ($request->isPost()) {
            if ($jsonFormat) {
                return array(
                    'status' => 'success',
                );
            }
            $this->notification()->success($event->getNotification());
            return $this->redirect()->toRoute('lang/applications/detail', array(), true);
        }

        if ($jsonFormat) {
            return $params;
        }

        /* @var \Applications\Form\Mail $form */
        $form = $this->forms->get('Applications/Mail');
        $form->populateValues($params);



        $recipient = $params['to'];

        return [
            'recipient' => $recipient,
            'form' => $form
        ];
    }
public function statusAction ( ) { $ applicationId = $ this -> params ( 'id' ) ; /* @var \Applications\Repository\Application $repository */ $ repository = $ this -> repositories -> get ( 'Applications/Application' ) ; /* @var Application $application */ $ application = $ repository -> find ( $ applicationId ) ; /* @var Request $request */ $ request = $ this -> getRequest ( ) ; if ( ! $ application ) { throw new \ InvalidArgumentException ( 'Could not find application.' ) ; } $ this -> acl ( $ application , 'change' ) ; $ jsonFormat = 'json' == $ this -> params ( ) -> fromQuery ( 'format' ) ; $ status = $ this -> params ( 'status' , Status :: CONFIRMED ) ; $ settings = $ this -> settings ( ) ; if ( in_array ( $ status , array ( Status :: INCOMING ) ) ) { $ application -> changeStatus ( $ status ) ; if ( $ request -> isXmlHttpRequest ( ) ) { $ response = $ this -> getResponse ( ) ; $ response -> setContent ( 'ok' ) ; return $ response ; } if ( $ jsonFormat ) { return array ( 'status' => 'success' , ) ; } return $ this -> redirect ( ) -> toRoute ( 'lang/applications/detail' , array ( ) , true ) ; } $ events = $ this -> appEvents ; /* @var ApplicationEvent $event */ $ event = $ events -> getEvent ( ApplicationEvent :: EVENT_APPLICATION_STATUS_CHANGE , $ this , [ 'application' => $ application , 'status' => $ status , 'user' => $ this -> auth ( ) -> getUser ( ) , ] ) ; $ event -> setIsPostRequest ( $ request -> isPost ( ) ) ; $ event -> setPostData ( $ request -> getPost ( ) ) ; $ events -> trigger ( $ event -> getName ( ) , $ event ) ; $ params = $ event -> getFormData ( ) ; if ( $ request -> isPost ( ) ) { if ( $ jsonFormat ) { return array ( 'status' => 'success' , ) ; } $ this -> notification ( ) -> success ( $ event -> getNotification ( ) ) ; return $ this -> redirect ( ) -> toRoute ( 'lang/applications/detail' , array ( ) , true ) ; } if ( $ jsonFormat ) { return $ params ; } /* @var \Applications\Form\Mail $form */ $ form = $ this -> forms -> get ( 'Applications/Mail' ) ; $ form -> populateValues ( $ params ) ; $ recipient = $ params [ 'to' ] ; return [ 'recipient' => $ recipient , 'form' => $ form ] ; }
Changes the status of an application

@return array
Changes the status of an application