# ConsultationController

Extends \NPS\Controller\AbstractController

Consultation related actions controller

author | Lukas Korinek
package | Default

### Methods

## __construct

    __construct(\Symfony\Component\HttpFoundation\RequestStack $stack)

inherited

### Arguments

#### $stack

`\Symfony\Component\HttpFoundation\RequestStack`

## Answers a consultation question

    answerAction(\NPS\Repository\ConsultationRepository $repo, \Symfony\Component\HttpFoundation\Request $request)

Route | ("/consultation/answer", methods={"POST"})

### Arguments

#### $repo

`\NPS\Repository\ConsultationRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

## Rewinds the consultation back by a question

    backAction(\NPS\Repository\ConsultationRepository $repo, \Symfony\Component\HttpFoundation\Request $request)

Route | ("/consultation/back", methods={"POST"})

### Arguments

#### $repo

`\NPS\Repository\ConsultationRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

## Creates a payload of consultation information

    createConsultationPayload(\NPS\Model\Consultation $consultation) : array

### Arguments

#### $consultation

`\NPS\Model\Consultation`

### Response

`array`

## Ends a consultation in progress

    endAction(\NPS\Repository\ConsultationRepository $repo, \Symfony\Component\HttpFoundation\Request $request)

Route | ("/consultation/end", methods={"POST"})

### Arguments

#### $repo

`\NPS\Repository\ConsultationRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

## Flushes any doctrine related changes

    flush()

inherited

## Seeks the consultation forward by a question

    forwardAction(\NPS\Repository\ConsultationRepository $repo, \Symfony\Component\HttpFoundation\Request $request)

Route | ("/consultation/forward", methods={"POST"})

### Arguments

#### $repo

`\NPS\Repository\ConsultationRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

## Gets current consultation state

    getAction(\NPS\Repository\ConsultationRepository $repo, \Symfony\Component\HttpFoundation\Request $request)

Route | ("/consultation/get")

### Arguments

#### $repo

`\NPS\Repository\ConsultationRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

## Returns current request

    getRequest() : \Symfony\Component\HttpFoundation\Request

inherited

### Response

`\Symfony\Component\HttpFoundation\Request`

## Lists user consultation history

    historyAction(\NPS\Repository\ConsultationRepository $historyRepo, \NPS\Repository\KnowledgeBaseRepository $knowledgeRepo, \Symfony\Component\HttpFoundation\Request $request)

Output is limited in verbosity for faster evaluation and lower data flow footprint

Route | ("/consultation/history")
Security | ("is_granted('ROLE_USER')")

### Arguments

#### $historyRepo

`\NPS\Repository\ConsultationRepository`

#### $knowledgeRepo

`\NPS\Repository\KnowledgeBaseRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

## Attempts to load a consultation either by request consultationId parameter or by looking for an active consultation

    resolveConsultation(\NPS\Repository\ConsultationRepository $repo, \Symfony\Component\HttpFoundation\Request $request) : \NPS\Model\Consultation

### Arguments

#### $repo

`\NPS\Repository\ConsultationRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

### Response

`\NPS\Model\Consultation`

## Creates a response

    response(array $data = array()) : \Symfony\Component\HttpFoundation\Response

inherited

### Arguments

#### $data

`array`

### Response

`\Symfony\Component\HttpFoundation\Response`

## Starts a new expert system consultation

    startAction(\NPS\Factory\ConsultationFactory $factory, \NPS\Repository\KnowledgeBaseRepository $baseRepository, \NPS\DependencyInjection\UserKnowledgeAccessGuard $guard, \Symfony\Component\HttpFoundation\Request $request)

Route | ("/consultation/start", methods={"POST"})

### Arguments

#### $factory

`\NPS\Factory\ConsultationFactory`

#### $baseRepository

`\NPS\Repository\KnowledgeBaseRepository`

#### $guard

`\NPS\DependencyInjection\UserKnowledgeAccessGuard`

#### $request

`\Symfony\Component\HttpFoundation\Request`

## Toggles a flag on a consultation

    toggleFlagAction(\NPS\Repository\ConsultationRepository $repo, \Symfony\Component\HttpFoundation\Request $request)

Route | ("/consultation/flag", methods={"POST"})
Security | ("is_granted('ROLE_USER')")

### Arguments

#### $repo

`\NPS\Repository\ConsultationRepository`

#### $request

`\Symfony\Component\HttpFoundation\Request`

### Properties

## Current request

    request : \Symfony\Component\HttpFoundation\Request

inherited

var | Current request

### Type(s)

`\Symfony\Component\HttpFoundation\Request`