New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PurchaceFlowの実装 #2424

Merged
merged 75 commits into from Jul 24, 2017
Commits
Jump to file or symbol
Failed to load files and symbols.
+4,477 −2,071
Diff settings

Always

Just for now

@@ -0,0 +1,39 @@
<?php
namespace Plugin\FormExtension\Form\Extension;
use Eccube\Form\Type\Front\EntryType;
use Eccube\Form\Type\Master\JobType;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\NotBlank;
class EntryTypeExtension extends AbstractTypeExtension
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
// 職業を必須項目に変更するサンプル
$builder->remove('job');
$builder->add(
'job',
JobType::class,
[
'required' => true,
'constraints' => [
new NotBlank(),
],
]
);
}
/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return EntryType::class;
}
}
@@ -0,0 +1,22 @@
<?php
namespace Plugin\FormExtension\ServiceProvider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Plugin\FormExtension\Form\Extension\EntryTypeExtension;
class FormExtensionServiceProvider implements ServiceProviderInterface
{
public function register(Container $app)
{
$app->extend(
'form.type.extensions',
function ($extensions) {
$extensions[] = new EntryTypeExtension();
return $extensions;
}
);
}
}
@@ -0,0 +1,5 @@
name: FormExtensionのサンプル
code: FormExtension
version: 1.0.0
service:
- FormExtensionServiceProvider
@@ -0,0 +1,22 @@
<?php
namespace Plugin\PurchaseProcessors\Processor;
use Eccube\Entity\ItemInterface;
use Eccube\Service\PurchaseFlow\ItemProcessor;
use Eccube\Service\PurchaseFlow\PurchaseContext;
use Eccube\Service\PurchaseFlow\ProcessResult;
class EmptyProcessor implements ItemProcessor
{
/**
* @param ItemInterface $item
* @param PurchaseContext $context
* @return ProcessResult
*/
public function process(ItemInterface $item, PurchaseContext $context)
{
log_info('empty processor executed', [__METHOD__]);
return ProcessResult::success();
}
}
@@ -0,0 +1,24 @@
<?php
namespace Plugin\PurchaseProcessors\Processor;
use Eccube\Entity\ItemInterface;
use Eccube\Service\PurchaseFlow\ItemValidateException;
use Eccube\Service\PurchaseFlow\PurchaseContext;
use Eccube\Service\PurchaseFlow\ValidatableItemProcessor;
class ValidatableEmptyProcessor extends ValidatableItemProcessor
{
protected function validate(ItemInterface $item, PurchaseContext $context)
{
$error = false;
if ($error) {
throw new ItemValidateException('ValidatableEmptyProcessorのエラーです');
}
}
protected function handle(ItemInterface $item, PurchaseContext $context)
{
$item->setQuantity(100);
}
}
@@ -0,0 +1,24 @@
<?php
namespace Plugin\PurchaseProcessors\ServiceProvider;
use Doctrine\Common\Collections\ArrayCollection;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Plugin\PurchaseProcessors\Processor\EmptyProcessor;
use Plugin\PurchaseProcessors\Processor\ValidatableEmptyProcessor;
class PurchaseProcessorsServiceProvider implements ServiceProviderInterface
{
public function register(Container $app)
{
$app->extend(
'eccube.purchase.flow.cart.item_processors',
function (ArrayCollection $processors, Container $app) {
$processors[] = new EmptyProcessor();
$processors[] = new ValidatableEmptyProcessor();
return $processors;
}
);
}
}
@@ -0,0 +1,5 @@
name: PurchaseFlowにProcessorを追加するサンプル
code: PurchaseProcessors
version: 1.0.0
service:
- PurchaseProcessorsServiceProvider
Copy path View file
@@ -75,7 +75,7 @@
"fzaninotto/faker":"1.5.*",
"phing/phing": "2.*",
"symfony/browser-kit": "3.3.*",
"friendsofphp/php-cs-fixer": "^1.11",
"friendsofphp/php-cs-fixer": "^2.2",
"satooshi/php-coveralls": "2.0.x-dev"
},
"autoload": {
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.