1. Go to this page and download the library: Download sylius/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.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sylius / flow-bundle example snippets
namespace Acme\Bundle\CheckoutBundle\Process\Scenario;
use Acme\Bundle\CheckoutBundle\Process\Step;
use Sylius\Bundle\FlowBundle\Process\Builder\ProcessBuilderInterface;
use Sylius\Bundle\FlowBundle\Process\Scenario\ProcessScenarioInterface;
/**
* My super checkout.
*
* @author Potato Potato <[email protected]>
*/
class CheckoutScenario implements ProcessScenarioInterface
{
/**
* {@inheritdoc}
*/
public function build(ProcessBuilderInterface $builder)
{
$builder
->add('security', new Step\SecurityStep())
->add('delivery', new Step\DeliveryStep())
->add('billing', 'acme_checkout_step_billing')
->add('finalize', new Step\FinalizeStep())
;
}
}
namespace Acme\Bundle\CheckoutBundle\Process\Step;
use Acme\Bundle\CheckoutBundle\Entity\Address;
use Sylius\Bundle\FlowBundle\Process\Context\ProcessContextInterface;
use Sylius\Bundle\FlowBundle\Process\Step\AbstractContainerAwareStep;
/**
* Delivery step.
* Allows user to select delivery method for order.
*
* @author Potato Potato <[email protected]>
*/
class DeliveryStep extends AbstractContainerAwareStep
{
/**
* {@inheritdoc}
*/
public function displayAction(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}
*/
public function forwardAction(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
*/
private function createAddressForm(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.