PHP code example of gmorel / state-workflow-bundle
1. Go to this page and download the library: Download gmorel/state-workflow-bundle library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gmorel / state-workflow-bundle example snippets
$bookingWorkflow = $this->get('demo.booking_engine.state_workflow');
// Initialize entity state to booking workflow default state : incomplete
// `Booking::__construct` contains `$bookingWorkflow->getDefaultState()->initialize($this);`
$booking = new Booking($bookingWorkflow, 200);
// Set incomplete Booking as paid
// Take care of the state transition (incomplete -> paid) - Send confirmation mail
$booking->getState($bookingWorkflow)
->setBookingAsPaid($booking);
// Get current booking state : StatePaid
$currentState = $booking->getState($bookingWorkflow);
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new Gmorel\StateWorkflowBundle\GmorelStateWorkflowBundle(),
);
// ...
}
// ...
}