2017 © Pedro Peláez
 

library flow-manager

Library to assist in the creation and management of complex wizard flows in projects using Symfony2's HttpFoundation component.

image

sidlee/flow-manager

Library to assist in the creation and management of complex wizard flows in projects using Symfony2's HttpFoundation component.

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

SidLee\Flow-Manager

Library to assist in the creation and management of complex wizard flows in projects using Symfony2's HttpFoundation component., (*1)

Library Maintainers

Usage

Creating a Step

In order to create a step, you must create a class implementing the interface SidLee\FlowManager\StepInterface. You may use SidLee\FlowManager\AbstractStep as a template if you wish., (*2)

use SidLee\FlowManager\AbstractStep;
use SidLee\FlowManager\NavigationResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class WizardStartStep extends AbstractStep
{
    public function handleRequest(Request $request, NavigationResponse $navResponse, $data) {
        return new Response("Hello World");
    }
}

In order to cause a navigation within the flow, simply return a SidLee\FlowManager\NavigationResponse instead of a Symfony\Component\HttpFoundation\Response., (*3)

use SidLee\FlowManager\AbstractStep;
use SidLee\FlowManager\NavigationDirection;
use SidLee\FlowManager\NavigationResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class WizardStartStep extends AbstractStep
{
    public function handleRequest(Request $request, NavigationResponse $navResponse, $data) {
        if($request->request->getAlpha('navigation') === 'NEXT') {
            return new NavigationResponse(NavigationDirection::NEXT());
        }
        return new Response("Hello World");
    }
}

Creating a flow

The wizard (or flow) is created and managed via a specialized collection called SidLee\FlowManager\StepCollection., (*4)

In order to create a flow, you must first populate your StepCollection with the desired steps (and names)., (*5)

use SidLee\FlowManager\StepCollection;

$stepCollection = new StepCollection();
$stepCollection->add('start', new WizardStartStep());
$stepCollection->add('accountInfo', new AccountInformationStep());
$stepCollection->add('confirmAccountInfo', new AccountInformationConfirmationStep());
$stepCollection->add('welcome', new WelcomeStep());

For more complex flows, you can also nest StepCollection instances (use add() with a StepCollection instead of a StepInterface)., (*6)

Using the created flow

Once the flow has been created, you must create an implementation of SidLee\FlowManager\AbstractFlowManager that will be able to manage the flow., (*7)

You must implement following functions:, (*8)

  • getCurrentStepName()
    This function is responsible for fetching the current step name from the underlying data source., (*9)

  • setCurrentStepNameToData() This function is responsible for setting the current step name in the underlying data source., (*10)

  • getNavigationHttpResponse() This function returns a Symfony\Component\HttpFoundation\Response whenever a navigation between steps is required., (*11)

Once your implementation is completed, you then have create a instance of your FlowManager by specifying a root key and the StepCollection representing your flow. You may also pass the desired EventDispatcher to be used for events., (*12)

Step Identifiers

Steps will be assigned a string identified based on the name and their nesting level in the StepCollection as well as the root key passed to the FlowManager., (*13)

Assuming that you have the following structure inside a StepCollection:, (*14)

- wizard_start
- registration_subflow
    - account_information
    - credentials_information
    - captcha
- download_client
- welcome

and that your root key in the FlowManager is "firstTimeSetup". The steps will be given the following fully qualified identifiers:, (*15)

- firstTimeSetup.wizard_start
- firstTimeSetup.registration_subflow.account_information
- firstTimeSetup.registration_subflow.credentials_information
- firstTimeSetup.registration_subflow.captcha
- firstTimeSetup.download_client
- firstTimeSetup.welcome

These identifiers can be used to navigate directly to a step using NavigationDirection::DIRECT()., (*16)

The Versions

08/06 2015

1.0.x-dev

1.0.9999999.9999999-dev

Library to assist in the creation and management of complex wizard flows in projects using Symfony2's HttpFoundation component.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Petitclerc

request flow http-foundation wizard

08/06 2015

1.0.0

1.0.0.0

Library to assist in the creation and management of complex wizard flows in projects using Symfony2's HttpFoundation component.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Petitclerc

request flow http-foundation wizard

08/06 2015

dev-master

9999999-dev

Library to assist in the creation and management of complex wizard flows in projects using Symfony2's HttpFoundation component.

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Daniel Petitclerc

request flow http-foundation wizard