1. Go to this page and download the library: Download metromix/flow-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.
<?phprequire_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
metromix / flow-bundle example snippets
namespaceAcme\Bundle\CheckoutBundle\Process\Scenario;
useAcme\Bundle\CheckoutBundle\Process\Step;
useSylius\Bundle\FlowBundle\Process\Builder\ProcessBuilderInterface;
useSylius\Bundle\FlowBundle\Process\Scenario\ProcessScenarioInterface;
/**
* My super checkout.
*
* @author Potato Potato <potato@potato.foo>
*/classCheckoutScenarioimplementsProcessScenarioInterface{
/**
* {@inheritdoc}
*/publicfunctionbuild(ProcessBuilderInterface $builder){
$builder
->add('security', new Step\SecurityStep())
->add('delivery', new Step\DeliveryStep())
->add('billing', 'acme_checkout_step_billing')
->add('finalize', new Step\FinalizeStep())
;
}
}
namespaceAcme\Bundle\CheckoutBundle\Process\Step;
useAcme\Bundle\CheckoutBundle\Entity\Address;
useSylius\Bundle\FlowBundle\Process\Context\ProcessContextInterface;
useSylius\Bundle\FlowBundle\Process\Step\AbstractContainerAwareStep;
/**
* Delivery step.
* Allows user to select delivery method for order.
*
* @author Potato Potato <potato@potato.foo>
*/classDeliveryStepextendsAbstractContainerAwareStep{
/**
* {@inheritdoc}
*/publicfunctiondisplayAction(ProcessContextInterface $context){
// All data is stored in a separate session bag with parameter namespace support.
$address = $context->getStorage()->get('delivery.address');
$form = $this->createAddressForm($address);
return$this->container->get('templating')->renderResponse('AcmeCheckoutBundle:Step:delivery.html.twig', array(
'form' => $form->createView(),
'context' => $context
));
}
/**
* {@inheritdoc}
*/publicfunctionforwardAction(ProcessContextInterface $context){
$request = $context->getRequest();
$form = $this->createAddressForm();
if ($form->handleRequest($request)->isValid()) {
$context->getStorage()->set('delivery.address', $form->getData());
return$this->complete();
}
// Form was not valid so we display the form again.return$this->container->get('templating')->renderResponse('AcmeCheckoutBundle:Step:delivery.html.twig', array(
'form' => $form->createView(),
'context' => $context
));
}
/**
* Create address form.
*
* @param Address $address
*
* @return FormInterface
*/privatefunctioncreateAddressForm(Address $address = null){
return$this->container->get('form.factory')->create('acme_checkout_address', $address);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.