dev-master
9999999-dev https://github.com/Coodit/SimpleWorkflowManagerA simple workflow to manage model steps easily.
MIT
The Requires
- php >=5.3.2
by Cédric Dugat
by Florent Mondoloni
collection simple manager workflow step
A simple workflow to manage model steps easily.
PHP library for easy workflow management., (*1)
Just add coo/simple-workflow-manager
package to the requirements of your Composer JSON configuration file,
and run php composer.phar install
to install it., (*2)
Clone this library from Git with git clone https://github.com/Coodit/SimpleWorkflow.git
., (*3)
Goto to the library directory, get Composer phar package and install vendors:, (*4)
curl -s https://getcomposer.org/installer | php php composer.phar install
You're ready to go., (*5)
First, you must create your first workflow. Here is an example:, (*6)
``` php getModel() to access your model * at any time. */ if ($this->getModel()->hasFooBarOption()) { $this->executePending(); } } public function executePending() { // Your logic. } public function executeDuring() { // Your logic. } public function executeComplete() { // Your logic. } /** * You must have a getModelStatus method to use * actual model status at any time. */ public function getModelStatus() { return $this->model->getStatus(); } } ``` ## Usage ``` php array(), 'during' => array('icon' => 'icon-during.png'), 'valid' => array('icon' => 'icon-valid.png'), 'complete' => array( 'icon' => 'icon-complete.png', 'other-parameter' => 'param' ), ); /** * Use default factory or create yours, based on it, or * call the manager from your DiC container. */ $workflowManager = WorkflowFactory::create($orderConfig); /** * Instanciate your specific worflow. */ $exampleWorkflow = new ExampleWorkFlow(); $exampleWorkflow->setModel(new ExampleEntity()); $workflowManager->setModelWorkflow($exampleWorkflow); /** * Steps calls examples. * * $workflowManager->executeCurrent(); * $workflowManager->executeNext(); * $workflowManager->executePrevious(); * $workflowManager->executeFirst(); * $workflowManager->executeLast(); * $workflowManager->executeToEnd(); * * You can jump to a specific step. * Use execute() to go to a step and executeTo() for * passing through each transitive ones. * Theses methods must have your step key as argument * ('pending', 'during', etc.). * * $workflowManager->execute('stepKey'); * $workflowManager->executeTo('stepKey') * * Here is an example: */ if ($workflowManager->executeNext()) { // Success. } else { // Fail. } ``` Here is an example to use step collection. ```shell , (*7)
<?php if ($step->hasProperty('icon')): ?> <span class="icon <?php echo $step->getProperty('icon') ?>"></span> <?php endif; ?> <?php echo $step ?> </li> <?php endforeach ?>
, (*8)
A simple workflow to manage model steps easily.
MIT
collection simple manager workflow step