pmPropelWorkflowableBehaviorPlugin - 1.0.0

Workflow behavior for propel objects

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

pmPropelWorkflowableBehaviorPlugin

The pmPropelWorkflowableBehaviorPlugin provides a behavior that adds workflow capabilities to a Propel object.

Installation

  • Install the plugin

    • via subversion

      $ svn co http://svn.symfony-project.com/plugins/pmPropelWorkflowableBehaviorPlugin/trunk pmPropelWorkflowableBehaviorPlugin
    • via the symfony plugin system

      $ ./symfony pl:i pmPropelWorkflowableBehaviorPlugin
  • Add the behavior in propel.ini file:

    propel.behavior.workflowable.class = plugins.pmPropelWorkflowableBehaviorPlugin.lib.WorkflowableBehavior

Usage

  • Add the behavior in your propel class:

    # in schema.yml file
    propel:
      purchase_order:
        item_name:
          type: varchar(255)
          required: true
        price:
          type: decimal
          size: 6
          scale: 2
          required: true
        status:
          type: integer
          default: 0
          required: true
        _propel_behaviors:
          workflowable:
            possible_status_values: 0, 1, 2
  • Rebuild your model

    $ ./symfony propel:build-model

Methods

  • stepForward: step forward in the workflow

    $purchase_order->stepForward();
  • stepBackward: step backward in the workflow

    $purchase_order->stepBackward();
  • canStepForward: returns true if the object can step forward in the workflow.

  • canStepBackward: returns true if the object can step backward in the workflow.

If the model contains a method named 'canStepForward' (or 'canStepBackward'), it's used to determine if the object can step forward (or can step backward). Otherwise, the object steps forward (or backward) only if the next (or previous) value is valid (is in possible_status_values array).

If the model can't step forward (or backward) an exeption is thrown.

TODO

  • Figure out how to jump between steps.