2017 © Pedro Peláez
 

symfony-bundle wizard-annotation-bundle

Simple wizard for a controller with validation methods

image

ibrows/wizard-annotation-bundle

Simple wizard for a controller with validation methods

  • Friday, July 20, 2018
  • by ibrows
  • Repository
  • 14 Watchers
  • 15 Stars
  • 7,492 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 13 Versions
  • 2 % Grown

The README.md

IbrowsWizardAnnotationBundle

Give's a Symfony2 controller a simple wizard/workflow with annotations., (*1)

How to install

Add Bundle to your composer.json

// composer.json

{
    "require": {
        "ibrows/wizard-annotation-bundle": "*"
    }
}

Install the bundle from console with composer.phar

``` bash $ php composer.phar update ibrows/wizard-annotation-bundle, (*2)


### Enable the bundle in AppKernel.php ``` php <?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Ibrows\Bundle\WizardAnnotationBundle\IbrowsWizardAnnotationBundle(), ); }

Using in a controller

``` php <?php, (*3)

namespace YourApp\Controller;, (*4)

use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\RedirectResponse;, (*5)

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;, (*6)

use Ibrows\Bundle\WizardAnnotationBundle\Annotation\Wizard;, (*7)

/** * @Route("/wizard") */ class WizardController extends Controller { /** * @Route("/register", name="wizard_register") * @Template * @Wizard(name="register", number=1) * @return array */ public function registerAction() { return array(); }, (*8)

/**
 * @Route("/address", name="wizard_address")
 * @Template
 * @Wizard(name="address", number=2, validationMethod="addressValidation")
 * @return array
 */
public function addressAction()
{
    return array();
}

/**
 * @return bool
 */
public function addressValidation()
{
    /**
     * Do your checks if this step is valid and return a Response/RedirectResponse or Wizard::REDIRECT_STEP_BACK
     * if something is wrong. Otherwise return true
     */

    if(!$this->getUser()){
        return Wizard::REDIRECT_STEP_BACK;
    }

    return true;
}

/**
 * @Route("/summary", name="wizard_summary")
 * @Template
 * @Wizard(name="summary", number=3, validationMethod="summaryValidation")
 * @return array
 */
public function summaryAction()
{
    return array();
}

/**
 * @return bool
 */
public function summaryValidation()
{
    /**
     * Do your checks if this step is valid and return a Response/RedirectResponse or Wizard::REDIRECT_STEP_BACK
     * if something is wrong. Otherwise return true
     */

    if(!$this->someCheck()){
        return new RedirectResponse($this->generateUrl('index'));
    }

    if(!$this->someOtherCheck()){
        return new RedirectResponse($this->generateUrl('login'));
    }

    return true;
}

/**
 * @Route("/display", name="wizard_display")
 * @Template
 * @return array
 */
public function displayAction()
{
    return array(
        'wizard' => $this->get('ibrows_wizardannotation.annotation.handler')
    );
}

}, (*9)


### Display the wizard Just render the wizardAction in the view: ``` html {% render "YourBundle:Wizard:display" %}

And the diplay.html.twig:, (*10)

html {% extends 'IbrowsWizardAnnotationBundle:Wizard:base.html.twig' %}, (*11)

The Versions

20/07 2018

dev-1.3.0-Symfony3.4

dev-1.3.0-Symfony3.4

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

04/10 2016

dev-master

9999999-dev

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

12/04 2016

1.3.0

1.3.0.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

24/02 2015

1.2.3

1.2.3.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

12/12 2014

1.2.2

1.2.2.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

11/12 2014

1.2.1

1.2.1.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

11/12 2014

1.2.0

1.2.0.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

09/12 2014

1.1.0

1.1.0.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

30/04 2014

1.0.4

1.0.4.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

22/05 2013

1.0.3

1.0.3.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

13/03 2013

1.0.0

1.0.0.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

13/03 2013

1.0.1

1.0.1.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows

13/03 2013

1.0.2

1.0.2.0

Simple wizard for a controller with validation methods

  Sources   Download

MIT

The Requires

 

annotation wizard ibrows