sylius/flow-bundle

此包已被放弃,不再维护。未建议替代包。

为 Symfony2 提供多个动作设置,构建需要多步完成的结账/安装程序等。

安装次数: 1,180,535

依赖者: 2

建议者: 0

安全: 0

星标: 87

关注者: 21

分支: 44

类型:symfony-bundle

v0.19.0 2016-05-24 12:26 UTC

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 Twitter 账户

如果您想了解最新更新,请关注 官方 Sylius Twitter 账户

错误跟踪

此包使用 GitHub 问题。如果您发现错误,请创建一个问题。

版本控制

版本号采用 major.minor.patch 格式。

并遵循以下准则。

  • 破坏向后兼容性会导致主要版本号增加。
  • 添加新功能而不破坏向后兼容性会导致次要版本号增加。
  • 错误修复和杂项更改会导致补丁版本号增加。

有关 SemVer 的更多信息,请访问 semver.org 网站。此版本控制方法适用于所有 Sylius 包和应用程序。

MIT 许可证

许可证可以在此处找到。

作者

该捆绑包最初由Paweł Jędrzejewski创建。查看贡献者列表