uk.gov.hmrc.play.fsm

# JourneyController

###
Related Doc: package fsm

#### trait JourneyController[RequestContext] extends AnyRef

Controller mixin for journeys implementing Finite State Machine.

Provides 3 main extension points:

- getCallFor: what is the endpoint representing given state
- renderState: how to render given state
- context: custom request context to carry over to the service layer

and actions DSL

Linear Supertypes
AnyRef, Any
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. JourneyController
2. AnyRef
3. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Type Members

1. #### sealed trait Executable extends AnyRef

   Interface of Action building components

2. #### type ExpectedStates = PartialFunction[State, Unit]

3. #### type Route = (Request[_]) ⇒ Result

4. #### type RouteFactory = (StateAndBreadcrumbs) ⇒ Route

5. #### type WithAuthorised[User] = (Request[_]) ⇒ ((User) ⇒ Future[Result]) ⇒ Future[Result]

### Abstract Value Members

1. #### abstract def context(implicit rh: RequestHeader): RequestContext

   Implement to provide customized request context you require in the service layer *

2. #### abstract def getCallFor(state: State)(implicit request: Request[_]): Call

   Implement to map states into endpoints for redirection and back linking

3. #### abstract val journeyService: JourneyService[RequestContext]

   This has to be injected in the concrete controller

4. #### abstract def renderState(state: State, breadcrumbs: Breadcrumbs, formWithErrors: Option[Form[_]])(implicit request: Request[_]): Result

   Implement to render state after transition or when form validation fails

### Concrete Value Members

1. #### final def !=(arg0: Any): Boolean

   Definition Classes
     AnyRef → Any

2. #### final def ##(): Int

   Definition Classes
     AnyRef → Any

3. #### final def ==(arg0: Any): Boolean

   Definition Classes
     AnyRef → Any

4. #### final def action(body: (Request[_]) ⇒ Future[Result])(implicit ec: ExecutionContext): Action[AnyContent]

   Creates an action for a given async result function.

   Creates an action for a given async result function.

   Attributes
     protected

5. #### final def actionShowState(expectedStates: ExpectedStates)(implicit ec: ExecutionContext): Action[AnyContent]

   Prefer to use DSL

   Prefer to use DSL

       actions.show[ExpectedState]

   Attributes
     protected

6. #### final def actionShowStateWhenAuthorised[User](withAuthorised: WithAuthorised[User])(expectedStates: ExpectedStates)(implicit ec: ExecutionContext): Action[AnyContent]

   Prefer to use DSL

   Prefer to use DSL

       actions.whenAuthorised(withAuthorised).show[ExpectedState]

   Attributes
     protected

7. #### object actions

   Collection of DSL-style action builders

8. #### final def apply(transition: Transition, routeFactory: RouteFactory)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

   Apply state transition and redirect to the URL matching the new state.

   Apply state transition and redirect to the URL matching the new state.

   Attributes
     protected

9. #### final def applyAndMatch(transition: Transition)(expectedStates: ExpectedStates)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

   Apply state transition and, depending on the outcome, display if the new state matches expectations, or redirect to the URL matching the new state.

   Apply state transition and, depending on the outcome, display if the new state matches expectations, or redirect to the URL matching the new state.

   Attributes
     protected

10. #### final def asInstanceOf[T0]: T0

    Definition Classes
      Any

11. #### def backLinkFor(breadcrumbs: Breadcrumbs)(implicit request: Request[_]): Call

    Returns a call to the previous state

    Returns a call to the previous state

    Attributes
      protected

12. #### final def bindForm[T](form: Form[T], transition: (T) ⇒ Transition)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Bind form and apply transition if success, otherwise redirect to the current state with form errors in the flash scope.

    Bind form and apply transition if success, otherwise redirect to the current state with form errors in the flash scope.

    Attributes
      protected

13. #### implicit def build(executable: Executable)(implicit ec: ExecutionContext): Action[AnyContent]

    Attributes
      protected

14. #### def clone(): AnyRef

    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

15. #### val display: RouteFactory

    Displays template for the state and breadcrumbs, eventually override to change details

16. #### final def eq(arg0: AnyRef): Boolean

    Definition Classes
      AnyRef

17. #### def equals(arg0: Any): Boolean

    Definition Classes
      AnyRef → Any

18. #### def finalize(): Unit

    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )

19. #### final def getClass(): Class[_]

    Definition Classes
      AnyRef → Any

20. #### final def hasState(filter: PartialFunction[State, Unit], stateAndBreadcrumbs: StateAndBreadcrumbs): Boolean

    Check if the expected state exists in the journey history (breadcrumbs).

    Check if the expected state exists in the journey history (breadcrumbs).

    Attributes
      protected
    Annotations
      @tailrec()

21. #### def hashCode(): Int

    Definition Classes
      AnyRef → Any

22. #### final def isInstanceOf[T0]: Boolean

    Definition Classes
      Any

23. #### final def ne(arg0: AnyRef): Boolean

    Definition Classes
      AnyRef

24. #### final def notify(): Unit

    Definition Classes
      AnyRef

25. #### final def notifyAll(): Unit

    Definition Classes
      AnyRef

26. #### val redirect: RouteFactory

    Redirects to the endpoint matching state, eventually override to change details

27. #### final def rewindTo(expectedState: PartialFunction[State, Unit])(fallback: ⇒ Future[Result])(stateAndBreadcrumbsOpt: Option[StateAndBreadcrumbs])(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Rewind journey state and history (breadcrumbs) back to the nearest state matching expectations.

    Rewind journey state and history (breadcrumbs) back to the nearest state matching expectations.

    Attributes
      protected

28. #### final def showState(expectedStates: ExpectedStates)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the state requested by the type parameter S.

    Display the state requested by the type parameter S. If the current state is not of type S, try to rewind the history back to the nearest state matching S, or redirect back to the root state.

    Attributes
      protected

29. #### final def showStateOrApply(expectedStates: ExpectedStates)(transition: Transition)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the journey state requested by the type parameter S.

    Display the journey state requested by the type parameter S. If the current state is not of type S, try to rewind the history back to the nearest state matching S, If there exists no matching state S in the history, apply the transition and redirect to the new state. If transition is not allowed then redirect back to the current state.

    Attributes
      protected

30. #### final def showStateUsingMerge[S <: State](expectedStates: ExpectedStates)(merger: Merger[S])(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the state requested by the type parameter S.

    Display the state requested by the type parameter S. If the current state is not of type S try to rewind the history back to the nearest state matching S and apply merge function to reconcile the new state with the previous state, or redirect back to the root state.

    Attributes
      protected

31. #### final def showStateUsingMergeOrApply[S <: State](expectedStates: ExpectedStates)(merger: Merger[S])(transition: Transition)(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Display the journey state requested by the type parameter S.

    Display the journey state requested by the type parameter S. If the current state is not of type S, try to rewind the history back to the nearest state matching S and apply merge function to reconcile the new state with the current state. If there exists no matching state S in the history, apply the transition and redirect to the new state. If transition is not allowed then redirect back to the current state.

    S

      type of the state to display

    Attributes
      protected

32. #### final def showStateWhenAuthorised[User](withAuthorised: WithAuthorised[User])(expectedStates: ExpectedStates)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    When user is authorized then render current state or rewind to the previous state matching expectation.

    When user is authorized then render current state or rewind to the previous state matching expectation.

    Attributes
      protected

33. #### final def showStateWhenAuthorisedUsingMerge[User, S <: State](withAuthorised: WithAuthorised[User])(expectedStates: ExpectedStates)(merge: Merger[S])(implicit arg0: ClassTag[S], rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Attributes
      protected

34. #### final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
      AnyRef

35. #### def toString(): String

    Definition Classes
      AnyRef → Any

36. #### final def wait(): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

37. #### final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

38. #### final def wait(arg0: Long): Unit

    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

39. #### final def whenAuthorised[User](withAuthorised: WithAuthorised[User])(transition: (User) ⇒ Transition)(routeFactory: RouteFactory)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Apply transition parametrized by an authorised user data.

    Apply transition parametrized by an authorised user data.

    Attributes
      protected

40. #### final def whenAuthorisedWithBootstrapAndForm[User, Payload, T](bootstrap: Transition)(withAuthorised: WithAuthorised[User])(form: Form[Payload])(transition: (User) ⇒ (Payload) ⇒ Transition)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Apply two transitions in order: - first: simple transition - second: transition parametrized by an authorised user data and form output

    Apply two transitions in order: - first: simple transition - second: transition parametrized by an authorised user data and form output

    Attributes
      protected

41. #### final def whenAuthorisedWithForm[User, Payload](withAuthorised: WithAuthorised[User])(form: Form[Payload])(transition: (User) ⇒ (Payload) ⇒ Transition)(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Apply transition parametrized by an authorised user data and form output.

    Apply transition parametrized by an authorised user data and form output.

    Attributes
      protected

42. #### def withValidRequest(body: ⇒ Future[Result])(implicit rc: RequestContext, request: Request[_], ec: ExecutionContext): Future[Result]

    Interceptor: override to do basic checks on every incoming request (headers, session, etc.)

### Inherited from AnyRef

### Inherited from Any

### Ungrouped