public function deleteAction()
    {
        $id          = $this->params('id');
        $repositories= $this->repositories;
        $repository  = $repositories->get('Applications/Application');
        $application = $repository->find($id);
        
        if (!$application) {
            throw new \DomainException('Application not found.');
        }

        $this->acl($application, 'delete');

        $events   = $this->appEvents;
        $events->trigger(ApplicationEvent::EVENT_APPLICATION_PRE_DELETE, $this, [ 'application' => $application ]);
        
        $repositories->remove($application);
        
        if ('json' == $this->params()->fromQuery('format')) {
            return ['status' => 'success'];
        }
        
        return $this->redirect()->toRoute('lang/applications', array(), true);
    }