metromix / flow-bundle
为Symfony2提供多种动作设置,构建您的结账/安装程序或需要多步完成的任何内容。
v0.19.1
2016-07-22 08:41 UTC
Requires
- php: ^5.6|^7.0
- symfony/framework-bundle: ^2.8|^3.0
Requires (Dev)
- phpspec/phpspec: ^2.4
- symfony/yaml: ~2.1
README
为Symfony2应用程序提供可重用步骤的多种动作流程。适用于构建结账或安装。
注意:此捆绑包是一个原型,它仅与最新版本的Symfony兼容。
Sylius
Sylius - 适用于Symfony2的现代电子商务。访问Sylius.org。
用法示例
<?php 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 <potato@potato.foo> */ 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()) ; } }
<?php 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 <potato@potato.foo> */ 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); } }
phpunit测试
$ composer install $ phpunit
文档
文档可在docs.sylius.org上找到。
代码示例
如果您想查看工作实现,请尝试Sylius沙盒应用程序。
贡献
有关为Sylius做出贡献的所有信息,请参阅此页面。
邮件列表
用户
有疑问?请随时在用户邮件列表上提问。
开发者
要为这个捆绑包做出贡献和开发,请使用开发者邮件列表。
Sylius推特账号
如果您想跟进更新,请关注Sylius官方推特账号。
错误跟踪
此捆绑包使用GitHub问题。如果您发现错误,请创建一个问题。
版本
版本将按照格式major.minor.patch
进行编号。
以下是以下指南。
- 破坏向后兼容性会增加主版本。
- 没有破坏向后兼容性的新功能会增加次版本。
- 错误修复和其它更改会增加补丁版本。
有关SemVer的更多信息,请访问semver.org网站。此版本方法适用于所有Sylius捆绑包和应用程序。
MIT许可
许可可以在此处找到。
作者
此捆绑包最初由Paweł Jędrzejewski创建。查看贡献者列表。