mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Initialize CustomerBundle
This commit is contained in:
parent
d14819e70d
commit
f26f57d0b5
72 changed files with 1136 additions and 445 deletions
|
|
@ -122,6 +122,7 @@
|
|||
"sylius/currency": "self.version",
|
||||
"sylius/currency-bundle": "self.version",
|
||||
"sylius/customer": "self.version",
|
||||
"sylius/customer-bundle": "self.version",
|
||||
"sylius/fixtures-bundle": "self.version",
|
||||
"sylius/flow-bundle": "self.version",
|
||||
"sylius/installer-bundle": "self.version",
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ suites:
|
|||
ContentBundle: { namespace: Sylius\Bundle\ContentBundle, psr4_prefix: Sylius\Bundle\ContentBundle, spec_path: src/Sylius/Bundle/ContentBundle, src_path: src/Sylius/Bundle/ContentBundle }
|
||||
CoreBundle: { namespace: Sylius\Bundle\CoreBundle, psr4_prefix: Sylius\Bundle\CoreBundle, spec_path: src/Sylius/Bundle/CoreBundle, src_path: src/Sylius/Bundle/CoreBundle }
|
||||
CurrencyBundle: { namespace: Sylius\Bundle\CurrencyBundle, psr4_prefix: Sylius\Bundle\CurrencyBundle, spec_path: src/Sylius/Bundle/CurrencyBundle, src_path: src/Sylius/Bundle/CurrencyBundle }
|
||||
CustomerBundle: { namespace: Sylius\Bundle\CustomerBundle, psr4_prefix: Sylius\Bundle\CustomerBundle, spec_path: src/Sylius/Bundle/CustomerBundle, src_path: src/Sylius/Bundle/CustomerBundle }
|
||||
FlowBundle: { namespace: Sylius\Bundle\FlowBundle, psr4_prefix: Sylius\Bundle\FlowBundle, spec_path: src/Sylius/Bundle/FlowBundle, src_path: src/Sylius/Bundle/FlowBundle }
|
||||
FixturesBundle: { namespace: Sylius\Bundle\FixturesBundle, psr4_prefix: Sylius\Bundle\FixturesBundle, spec_path: src/Sylius/Bundle/FixturesBundle, src_path: src/Sylius/Bundle/FixturesBundle }
|
||||
GridBundle: { namespace: Sylius\Bundle\GridBundle, psr4_prefix: Sylius\Bundle\GridBundle, spec_path: src/Sylius/Bundle/GridBundle, src_path: src/Sylius/Bundle/GridBundle }
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class Kernel extends HttpKernel
|
|||
new \Sylius\Bundle\ContentBundle\SyliusContentBundle(),
|
||||
new \Sylius\Bundle\RbacBundle\SyliusRbacBundle(),
|
||||
new \Sylius\Bundle\UserBundle\SyliusUserBundle(),
|
||||
new \Sylius\Bundle\CustomerBundle\SyliusCustomerBundle(),
|
||||
new \Sylius\Bundle\UiBundle\SyliusUiBundle(),
|
||||
new \Sylius\Bundle\AdminBundle\SyliusAdminBundle(),
|
||||
new \Sylius\Bundle\ShopBundle\SyliusShopBundle(),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Controller;
|
||||
|
||||
use Sylius\Bundle\UserBundle\Controller\CustomerController as BaseCustomerController;
|
||||
use Sylius\Bundle\CustomerBundle\Controller\CustomerController as BaseCustomerController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,60 +9,16 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Doctrine\ORM;
|
||||
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
use Sylius\Component\Customer\Repository\CustomerRepositoryInterface;
|
||||
use Sylius\Bundle\CustomerBundle\Doctrine\ORM\CustomerRepository as BaseCustomerRepository;
|
||||
use Sylius\Component\Core\Repository\CustomerRepositoryInterface;
|
||||
|
||||
/**
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
* @author Anna Walasek <anna.walasek@lakion.com>
|
||||
*/
|
||||
class CustomerRepository extends EntityRepository implements CustomerRepositoryInterface
|
||||
class CustomerRepository extends BaseCustomerRepository implements CustomerRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return (int) $this->createQueryBuilder('o')
|
||||
->select('COUNT(o.id)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findLatest($count)
|
||||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->addOrderBy('o.createdAt', 'desc')
|
||||
->setMaxResults($count)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findForDetailsPage($id)
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('o');
|
||||
$queryBuilder
|
||||
->andWhere($queryBuilder->expr()->eq('o.id', ':id'))
|
||||
->setParameter('id', $id)
|
||||
;
|
||||
|
||||
$result = $queryBuilder
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\EventSubscriber;
|
||||
namespace Sylius\Bundle\CoreBundle\Form\EventSubscriber;
|
||||
|
||||
use Sylius\Component\Customer\Model\CustomerAwareInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
|
@ -14,7 +14,7 @@ namespace Sylius\Bundle\CoreBundle\Form\Type\Checkout;
|
|||
use Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddDefaultBillingAddressOnOrderFormSubscriber;
|
||||
use Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddEmailGuestFormSubscriber;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Sylius\Bundle\UserBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber;
|
||||
use Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type\Rule;
|
||||
|
||||
use Sylius\Bundle\UserBundle\Doctrine\ORM\GroupRepository;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
|
@ -23,14 +23,14 @@ use Symfony\Component\Validator\Constraints\Type;
|
|||
class CustomerGroupType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @var GroupRepository
|
||||
* @var RepositoryInterface
|
||||
*/
|
||||
protected $groupRepository;
|
||||
|
||||
/**
|
||||
* @param GroupRepository $groupRepository
|
||||
* @param RepositoryInterface $groupRepository
|
||||
*/
|
||||
public function __construct(GroupRepository $groupRepository)
|
||||
public function __construct(RepositoryInterface $groupRepository)
|
||||
{
|
||||
$this->groupRepository = $groupRepository;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ imports:
|
|||
- { resource: "@SyliusContactBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusContentBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusCurrencyBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusCustomerBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusInventoryBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusLocaleBundle/Resources/config/app/config.yml" }
|
||||
- { resource: "@SyliusOrderBundle/Resources/config/app/config.yml" }
|
||||
|
|
|
|||
|
|
@ -743,6 +743,7 @@ sylius_user:
|
|||
customer:
|
||||
classes:
|
||||
model: Sylius\Component\Core\Model\Customer
|
||||
repository: Sylius\Bundle\CoreBundle\Doctrine\ORM\CustomerRepository
|
||||
controller: Sylius\Bundle\CoreBundle\Controller\CustomerController
|
||||
|
||||
sylius_variation:
|
||||
|
|
|
|||
|
|
@ -55,7 +55,10 @@
|
|||
<parameter key="sylius.form.type.promotion_action.add_product_configuration.class">Sylius\Bundle\CoreBundle\Form\Type\Action\AddProductConfigurationType</parameter>
|
||||
|
||||
<parameter key="sylius.form.type.data_transformer.taxons_to_codes.class">Sylius\Bundle\CoreBundle\Form\DataTransformer\TaxonsToCodesTransformer</parameter>
|
||||
|
||||
<parameter key="sylius.form.type.customer_guest.class">Sylius\Bundle\CoreBundle\Form\Type\CustomerGuestType</parameter>
|
||||
<parameter key="sylius.form.type.customer_registration.class">Sylius\Bundle\CoreBundle\Form\Type\CustomerRegistrationType</parameter>
|
||||
<parameter key="sylius.form.type.customer_simple_registration.class">Sylius\Bundle\CoreBundle\Form\Type\CustomerSimpleRegistrationType</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
|
|
@ -203,9 +206,31 @@
|
|||
</service>
|
||||
|
||||
<!-- customer -->
|
||||
<service id="sylius.form.type.customer" class="%sylius.form.type.customer.class%">
|
||||
<argument>%sylius.model.customer.class%</argument>
|
||||
<argument type="collection">
|
||||
<argument>sylius</argument>
|
||||
</argument>
|
||||
<argument type="service" id="sylius.form.event_subscriber.add_user_type" />
|
||||
</service>
|
||||
<service id="sylius.form.type.customer_guest" class="%sylius.form.type.customer_guest.class%">
|
||||
<argument type="service" id="sylius.form.event_subscriber.set_customer" />
|
||||
</service>
|
||||
<service id="sylius.form.type.customer_simple_registration" class="%sylius.form.type.customer_simple_registration.class%">
|
||||
<argument>%sylius.model.customer.class%</argument>
|
||||
<argument type="collection">
|
||||
<argument>sylius</argument>
|
||||
</argument>
|
||||
<argument type="service" id="sylius.repository.customer" />
|
||||
</service>
|
||||
<service id="sylius.form.type.customer_registration" class="%sylius.form.type.customer_registration.class%">
|
||||
<argument>%sylius.model.customer.class%</argument>
|
||||
<argument type="collection">
|
||||
<argument>sylius</argument>
|
||||
</argument>
|
||||
<argument type="service" id="sylius.repository.customer" />
|
||||
</service>
|
||||
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@
|
|||
<parameter key="sylius.listener.customer_reviews_delete.class">Sylius\Bundle\CoreBundle\EventListener\CustomerReviewsDeleteListener</parameter>
|
||||
<parameter key="sylius.listener.order_recalculation.class">Sylius\Bundle\CoreBundle\EventListener\OrderRecalculationListener</parameter>
|
||||
<parameter key="sylius.listener.user_cart_recalculation.class">Sylius\Bundle\CoreBundle\EventListener\UserCartRecalculationListener</parameter>
|
||||
<parameter key="sylius.listener.default_username.class">Sylius\Bundle\CoreBundle\EventListener\DefaultUsernameORMListener</parameter>
|
||||
<parameter key="sylius.listener.user_auto_login.class">Sylius\Bundle\CoreBundle\EventListener\UserAutoLoginListener</parameter>
|
||||
|
||||
<parameter key="sylius.active_promotions_by_channel_provider.class">Sylius\Component\Core\Provider\ActivePromotionsByChannelProvider</parameter>
|
||||
|
||||
|
|
@ -102,6 +104,8 @@
|
|||
<parameter key="sylius.route_provider.class">Sylius\Bundle\CoreBundle\Routing\RouteProvider</parameter>
|
||||
|
||||
<parameter key="sylius.validator.has_enabled_entity.class">Sylius\Bundle\CoreBundle\Validator\Constraints\HasEnabledEntityValidator</parameter>
|
||||
<parameter key="sylius.validator.customer_initializer.class">Sylius\Bundle\CoreBundle\Validator\Initializer\CustomerInitializer</parameter>
|
||||
<parameter key="sylius.user.validator.unique_registered_user.class">Sylius\Bundle\CoreBundle\Validator\Constraints\RegisteredUserValidator</parameter>
|
||||
|
||||
<parameter key="sylius.sql_logger.purger.purge_mode" type="constant">Doctrine\Common\DataFixtures\Purger\ORMPurger::PURGE_MODE_DELETE</parameter>
|
||||
<parameter key="sylius.sql_logger.purger.class">Sylius\Bundle\CoreBundle\Purger\QueryLogger</parameter>
|
||||
|
|
@ -118,6 +122,10 @@
|
|||
|
||||
<parameter key="sylius.context.customer.class">Sylius\Bundle\CoreBundle\Context\CustomerContext</parameter>
|
||||
|
||||
<!-- Form subscriber -->
|
||||
<parameter key="sylius.form.event_subscriber.set_customer_type.class">Sylius\Bundle\CoreBundle\Form\EventSubscriber\SetCustomerFormSubscriber</parameter>
|
||||
<parameter key="sylius.form.event_subscriber.add_user_type.class">Sylius\Bundle\UserBundle\Form\EventSubscriber\CoreUserFormSubscriber</parameter>
|
||||
|
||||
<!-- Data fetchers -->
|
||||
<parameter key="sylius.form.type.data_fetcher.number_of_orders.class">Sylius\Bundle\CoreBundle\Form\Type\DataFetcher\NumberOfOrdersType</parameter>
|
||||
<parameter key="sylius.form.type.data_fetcher.sales_total.class">Sylius\Bundle\CoreBundle\Form\Type\DataFetcher\SalesTotalType</parameter>
|
||||
|
|
@ -359,6 +367,13 @@
|
|||
<tag name="kernel.event_listener" event="sylius.user.security.implicit_login" method="recalculateCartWhileLogin" />
|
||||
<tag name="kernel.event_listener" event="security.interactive_login" method="recalculateCartWhileLogin" />
|
||||
</service>
|
||||
<service id="sylius.listener.default_username" class="%sylius.listener.default_username.class%">
|
||||
<tag name="doctrine.event_listener" event="onFlush" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_auto_login" class="%sylius.listener.user_auto_login.class%">
|
||||
<argument type="service" id="sylius.security.user_login" />
|
||||
<tag name="kernel.event_listener" event="sylius.customer.post_register" method="login" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.active_promotions_by_channel_provider" class="%sylius.active_promotions_by_channel_provider.class%">
|
||||
<argument type="service" id="sylius.repository.promotion" />
|
||||
|
|
@ -503,6 +518,7 @@
|
|||
<service id="sylius.form.event_subscriber.set_customer" class="%sylius.form.event_subscriber.set_customer_type.class%">
|
||||
<argument type="service" id="sylius.repository.customer" />
|
||||
</service>
|
||||
<service id="sylius.form.event_subscriber.add_user_type" class="%sylius.form.event_subscriber.add_user_type.class%" />
|
||||
|
||||
<!-- Data fetchers -->
|
||||
<service id="sylius.form.type.data_fetcher.user_registration" class="%sylius.form.type.data_fetcher.user_registration.class%">
|
||||
|
|
@ -526,6 +542,14 @@
|
|||
<argument type="service" id="doctrine" />
|
||||
<tag name="validator.constraint_validator" alias="sylius_has_enabled_entity" />
|
||||
</service>
|
||||
<service id="sylius.validator.customer_initializer" class="%sylius.validator.customer_initializer.class%">
|
||||
<argument type="service" id="sylius.user.canonicalizer" />
|
||||
<tag name="validator.initializer" />
|
||||
</service>
|
||||
<service id="validator.unique.registered_user" class="%sylius.user.validator.unique_registered_user.class%">
|
||||
<argument type="service" id="sylius.repository.customer" />
|
||||
<tag name="validator.constraint_validator" alias="registered_user_validator" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Doctrine\ORM;
|
||||
namespace spec\Sylius\Bundle\CoreBundle\Doctrine\ORM;
|
||||
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
|
@ -31,7 +31,7 @@ final class CustomerRepositorySpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Doctrine\ORM\CustomerRepository');
|
||||
$this->shouldHaveType('Sylius\Bundle\CoreBundle\Doctrine\ORM\CustomerRepository');
|
||||
}
|
||||
|
||||
function it_is_a_repository()
|
||||
|
|
@ -39,22 +39,6 @@ final class CustomerRepositorySpec extends ObjectBehavior
|
|||
$this->shouldHaveType(EntityRepository::class);
|
||||
}
|
||||
|
||||
function it_finds_details($em, QueryBuilder $builder, Expr $expr, AbstractQuery $query)
|
||||
{
|
||||
$builder->expr()->shouldBeCalled()->willReturn($expr);
|
||||
$expr->eq('o.id', ':id')->shouldBeCalled()->willReturn($expr);
|
||||
|
||||
$em->createQueryBuilder()->shouldBeCalled()->willReturn($builder);
|
||||
$builder->select('o')->shouldBeCalled()->willReturn($builder);
|
||||
$builder->from(Argument::any(), 'o', Argument::cetera())->shouldBeCalled()->willReturn($builder);
|
||||
$builder->andWhere($expr)->shouldBeCalled()->willReturn($builder);
|
||||
$builder->setParameter('id', 1)->shouldBeCalled()->willReturn($builder);
|
||||
$builder->getQuery()->shouldBeCalled()->willReturn($query);
|
||||
$query->getOneOrNullResult()->shouldBeCalled();
|
||||
|
||||
$this->findForDetailsPage(1);
|
||||
}
|
||||
|
||||
function it_creates_paginator(
|
||||
$em,
|
||||
QueryBuilder $builder,
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Form\EventSubscriber;
|
||||
namespace spec\Sylius\Bundle\CoreBundle\Form\EventSubscriber;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Bundle\UserBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber;
|
||||
use Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber;
|
||||
use Sylius\Component\Resource\Model\ResourceInterface;
|
||||
use Sylius\Component\Customer\Model\CustomerAwareInterface;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
use Sylius\Component\Core\Model\CustomerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Form\FormConfigInterface;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
|
|
@ -36,7 +36,7 @@ final class AddCustomerGuestTypeFormSubscriberSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber');
|
||||
$this->shouldHaveType('Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber');
|
||||
}
|
||||
|
||||
function it_is_an_event_subscriber()
|
||||
|
|
@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior;
|
|||
use Prophecy\Argument;
|
||||
use Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddDefaultBillingAddressOnOrderFormSubscriber;
|
||||
use Sylius\Bundle\CoreBundle\Form\Type\Checkout\AddressingType;
|
||||
use Sylius\Bundle\UserBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber;
|
||||
use Sylius\Bundle\CoreBundle\Form\EventSubscriber\AddCustomerGuestTypeFormSubscriber;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
|
|
|||
5
src/Sylius/Bundle/CustomerBundle/.gitignore
vendored
Normal file
5
src/Sylius/Bundle/CustomerBundle/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
vendor/
|
||||
bin/
|
||||
|
||||
composer.phar
|
||||
composer.lock
|
||||
6
src/Sylius/Bundle/CustomerBundle/CHANGELOG.md
Normal file
6
src/Sylius/Bundle/CustomerBundle/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
### v1.0.0-alpha.1
|
||||
|
||||
* Initial dev release.
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Controller;
|
||||
namespace Sylius\Bundle\CustomerBundle\Controller;
|
||||
|
||||
use FOS\RestBundle\View\View;
|
||||
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
|
||||
|
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CustomerBundle\DependencyInjection;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceChoiceType;
|
||||
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
|
||||
use Sylius\Bundle\CustomerBundle\Controller\CustomerController;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceFromIdentifierType;
|
||||
use Sylius\Bundle\CustomerBundle\Form\Type\CustomerProfileType;
|
||||
use Sylius\Bundle\CustomerBundle\Form\Type\CustomerType;
|
||||
use Sylius\Bundle\CustomerBundle\Form\Type\GroupType;
|
||||
use Sylius\Component\Resource\Factory\Factory;
|
||||
use Sylius\Component\Customer\Model\Customer;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
use Sylius\Component\Customer\Model\Group;
|
||||
use Sylius\Component\Customer\Model\GroupInterface;
|
||||
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
|
||||
/**
|
||||
* This class contains the configuration information for the bundle.
|
||||
*
|
||||
* This information is solely responsible for how the different configuration
|
||||
* sections are normalized, and merged.
|
||||
*
|
||||
* @author Bartosz Siejka <bartosz.siejka@lakion.com>
|
||||
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('sylius_customer');
|
||||
|
||||
$rootNode
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end()
|
||||
;
|
||||
|
||||
$this->addResourcesSection($rootNode);
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addResourcesSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('resources')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('customer')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->variableNode('options')->end()
|
||||
->arrayNode('classes')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue(Customer::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('interface')->defaultValue(CustomerInterface::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('controller')->defaultValue(CustomerController::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('repository')->cannotBeEmpty()->end()
|
||||
->scalarNode('factory')->defaultValue(Factory::class)->end()
|
||||
->arrayNode('form')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('default')->defaultValue(CustomerType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('profile')->defaultValue(CustomerProfileType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('validation_groups')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('default')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius'])
|
||||
->end()
|
||||
->arrayNode('profile')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius', 'sylius_customer_profile'])
|
||||
->end()
|
||||
->arrayNode('registration')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius', 'sylius_customer_profile', 'sylius_user_registration'])
|
||||
->end()
|
||||
->arrayNode('simple_registration')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius', 'sylius_user_registration'])
|
||||
->end()
|
||||
->arrayNode('guest')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius_customer_guest'])
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('group')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->variableNode('options')->end()
|
||||
->arrayNode('classes')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue(Group::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('interface')->defaultValue(GroupInterface::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('repository')->cannotBeEmpty()->end()
|
||||
->scalarNode('factory')->defaultValue(Factory::class)->end()
|
||||
->arrayNode('form')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('default')->defaultValue(GroupType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('from_identifier')->defaultValue(ResourceFromIdentifierType::class)->cannotBeEmpty()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('validation_groups')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('default')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius'])
|
||||
->end()
|
||||
->arrayNode('from_identifier')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius'])
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CustomerBundle\DependencyInjection;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\DependencyInjection\Extension\AbstractResourceExtension;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
|
||||
*/
|
||||
class SyliusCustomerExtension extends AbstractResourceExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $config, ContainerBuilder $container)
|
||||
{
|
||||
$config = $this->processConfiguration($this->getConfiguration($config, $container), $config);
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
||||
$loader->load(sprintf('driver/%s.xml', $config['driver']));
|
||||
|
||||
$this->registerResources('sylius', $config['driver'], $config['resources'], $container);
|
||||
|
||||
$loader->load('services.xml');
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CustomerBundle\Doctrine\ORM;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
use Sylius\Component\Customer\Repository\CustomerRepositoryInterface;
|
||||
|
||||
/**
|
||||
* @author Michał Marcinkowski <michal.marcinkowski@lakion.com>
|
||||
*/
|
||||
class CustomerRepository extends EntityRepository implements CustomerRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
return (int) $this->createQueryBuilder('o')
|
||||
->select('COUNT(o.id)')
|
||||
->getQuery()
|
||||
->getSingleScalarResult()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findLatest($count)
|
||||
{
|
||||
return $this->createQueryBuilder('o')
|
||||
->addOrderBy('o.createdAt', 'desc')
|
||||
->setMaxResults($count)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function findForDetailsPage($id)
|
||||
{
|
||||
$queryBuilder = $this->createQueryBuilder('o');
|
||||
$queryBuilder
|
||||
->andWhere($queryBuilder->expr()->eq('o.id', ':id'))
|
||||
->setParameter('id', $id)
|
||||
;
|
||||
|
||||
$result = $queryBuilder
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\EventSubscriber;
|
||||
namespace Sylius\Bundle\CustomerBundle\Form\EventSubscriber;
|
||||
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
|
|
@ -9,10 +9,10 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Sylius\Bundle\UserBundle\Form\EventSubscriber\CustomerRegistrationFormSubscriber;
|
||||
use Sylius\Bundle\CustomerBundle\Form\EventSubscriber\CustomerRegistrationFormSubscriber;
|
||||
use Sylius\Bundle\UserBundle\Form\EventSubscriber\UserRegistrationFormSubscriber;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
64
src/Sylius/Bundle/CustomerBundle/README.md
Normal file
64
src/Sylius/Bundle/CustomerBundle/README.md
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
SyliusCustomerBundle [](http://travis-ci.org/Sylius/SyliusCustomerBundle)
|
||||
==================
|
||||
|
||||
[**Symfony2**](http://symfony.com) integration of Sylius Customer processing
|
||||
component.
|
||||
|
||||
Sylius
|
||||
------
|
||||
|
||||
**Sylius** - Modern ecommerce for Symfony2. Visit [Sylius.org](http://sylius.org).
|
||||
|
||||
[phpspec](http://phpspec.net) examples
|
||||
--------------------------------------
|
||||
|
||||
```bash
|
||||
$ composer install
|
||||
$ bin/phpspec run -f pretty
|
||||
```
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
Documentation is available on [**docs.sylius.org**](http://sylius.org/en/latest/bundles/SyliusCustomerBundle/index.html).
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
All informations about contributing to Sylius can be found on [this page](http://docs.sylius.org/en/latest/contributing/index.html).
|
||||
|
||||
Sylius twitter account
|
||||
----------------------
|
||||
|
||||
If you want to keep up with updates, [follow the official Sylius account on twitter](http://twitter.com/Sylius).
|
||||
|
||||
Bug tracking
|
||||
------------
|
||||
|
||||
This bundle uses [GitHub issues](https://github.com/Sylius/SyliusCustomerBundle/issues).
|
||||
If you have found bug, please create an issue.
|
||||
|
||||
Versioning
|
||||
----------
|
||||
|
||||
Releases will be numbered with the format `major.minor.patch`.
|
||||
|
||||
And constructed with the following guidelines.
|
||||
|
||||
* Breaking backwards compatibility bumps the major.
|
||||
* New additions without breaking backwards compatibility bumps the minor.
|
||||
* Bug fixes and misc changes bump the patch.
|
||||
|
||||
For more information on SemVer, please visit [semver.org website](http://semver.org/)...
|
||||
This versioning method is same for all **Sylius** bundles and applications.
|
||||
|
||||
MIT License
|
||||
-----------
|
||||
|
||||
License can be found [here](https://github.com/Sylius/SyliusCustomerBundle/blob/master/Resources/meta/LICENSE).
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
The bundle was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com).
|
||||
See the list of [contributors](https://github.com/Sylius/SyliusCustomerBundle/contributors).
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# This file is part of the Sylius package.
|
||||
# (c) Paweł Jędrzejewski
|
||||
|
||||
jms_serializer:
|
||||
metadata:
|
||||
directories:
|
||||
sylius-user:
|
||||
namespace_prefix: "Sylius\\Component\\Customer"
|
||||
path: "@SyliusCustomerBundle/Resources/config/serializer"
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
|
||||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Sylius\Component\User\Model\Group" table="sylius_group">
|
||||
<mapped-superclass name="Sylius\Component\Customer\Model\Group" table="sylius_group">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services
|
||||
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius.repository.customer.class">Sylius\Bundle\CustomerBundle\Doctrine\ORM\CustomerRepository</parameter>
|
||||
</parameters>
|
||||
|
||||
</container>
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
sylius_register:
|
||||
resource: @SyliusCustomerBundle/Resources/config/routing/registration.yml
|
||||
|
||||
sylius_account:
|
||||
resource: @SyliusCustomerBundle/Resources/config/routing/account.yml
|
||||
prefix: /account
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
# This file is part of the Sylius package.
|
||||
# (c) Paweł Jędrzejewski
|
||||
|
||||
sylius_account_profile_show:
|
||||
path: /
|
||||
methods: [GET]
|
||||
defaults:
|
||||
_controller: sylius.controller.customer:showProfileAction
|
||||
|
||||
sylius_account_profile_update:
|
||||
path: /profile/edit
|
||||
methods: [GET, POST]
|
||||
defaults:
|
||||
_controller: sylius.controller.customer:updateProfileAction
|
||||
_sylius:
|
||||
form: sylius_customer_profile
|
||||
redirect: sylius_account_profile_show
|
||||
|
||||
sylius_account_change_password:
|
||||
path: /change-password
|
||||
methods: [GET, POST]
|
||||
defaults:
|
||||
_controller: sylius.controller.user:changePasswordAction
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
sylius_user_registration:
|
||||
path: /register
|
||||
methods: [GET, POST]
|
||||
defaults:
|
||||
_controller: sylius.controller.customer:createAction
|
||||
_sylius:
|
||||
form: sylius_customer_registration
|
||||
event: register
|
||||
template: SyliusCustomerBundle::register.html.twig
|
||||
redirect: referer
|
||||
permission: false
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<container xmlns="http://symfony.com/schema/dic/services"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/services
|
||||
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius.form.type.gender.class">Sylius\Bundle\UserBundle\Form\Type\GenderType</parameter>
|
||||
<parameter key="sylius.listener.customer_aware.class">Sylius\Bundle\UserBundle\EventListener\CustomerAwareListener</parameter>
|
||||
<parameter key="sylius.form.event_subscriber.set_customer_type.class">Sylius\Bundle\UserBundle\Form\EventSubscriber\SetCustomerFormSubscriber</parameter>
|
||||
<parameter key="sylius.user.validator.customer_initializer.class">Sylius\Bundle\UserBundle\Validator\Initializer\CustomerInitializer</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.form.type.gender" class="%sylius.form.type.gender.class%">
|
||||
<tag name="form.type" alias="sylius_gender" />
|
||||
</service>
|
||||
|
||||
<!-- Form event subscribers-->
|
||||
<service id="sylius.form.event_subscriber.add_user_type" class="%sylius.form.event_subscriber.add_user_type.class%" />
|
||||
|
||||
<!-- Validators -->
|
||||
<service id="sylius.user.validator.customer_initializer" class="%sylius.user.validator.customer_initializer.class%">
|
||||
<argument type="service" id="sylius.user.canonicalizer" />
|
||||
<tag name="validator.initializer" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
102
src/Sylius/Bundle/CustomerBundle/Resources/config/validation.xml
Normal file
102
src/Sylius/Bundle/CustomerBundle/Resources/config/validation.xml
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Paweł Jędrzejewski
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
|
||||
http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
|
||||
|
||||
<class name="Sylius\Component\Customer\Model\Customer">
|
||||
<constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
|
||||
<option name="message">sylius.customer.email.unique</option>
|
||||
<option name="fields">emailCanonical</option>
|
||||
<option name="errorPath">email</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<property name="firstName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.first_name.not_blank</option>
|
||||
<option name="groups">sylius_customer_profile</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.customer.first_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.customer.first_name.max</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="lastName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.last_name.not_blank</option>
|
||||
<option name="groups">sylius_customer_profile</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.customer.last_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.customer.last_name.max</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="gender">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.gender.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="email">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.email.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
<value>sylius_customer_guest</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.customer.email.min</option>
|
||||
<option name="max">254</option>
|
||||
<option name="maxMessage">sylius.customer.email.max</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
<value>sylius_customer_guest</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Email">
|
||||
<option name="message">sylius.customer.email.invalid</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
<value>sylius_customer_guest</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Component\Customer\Model\Group">
|
||||
<property name="name">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.group.name.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.group.name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.group.name.max</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
</constraint-mapping>
|
||||
19
src/Sylius/Bundle/CustomerBundle/Resources/meta/LICENSE
Normal file
19
src/Sylius/Bundle/CustomerBundle/Resources/meta/LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2011-2016 Paweł Jędrzejewski
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
Sylius\Component\User\Model\Customer:
|
||||
exclusion_policy: ALL
|
||||
xml_root_name: sylius_customer
|
||||
properties:
|
||||
id:
|
||||
expose: true
|
||||
type: integer
|
||||
groups: [Default, Detailed]
|
||||
email:
|
||||
expose: true
|
||||
type: string
|
||||
groups: [Default, Detailed]
|
||||
emailCanonical:
|
||||
expose: true
|
||||
type: string
|
||||
groups: [Detailed]
|
||||
firstName:
|
||||
expose: true
|
||||
type: string
|
||||
groups: [Default, Detailed]
|
||||
lastName:
|
||||
expose: true
|
||||
type: string
|
||||
groups: [Default, Detailed]
|
||||
gender:
|
||||
expose: true
|
||||
type: string
|
||||
groups: [Detailed]
|
||||
birthday:
|
||||
expose: true
|
||||
type: DateTime
|
||||
groups: [Detailed]
|
||||
groups:
|
||||
expose: true
|
||||
type: array
|
||||
groups: [Detailed]
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
sylius:
|
||||
form:
|
||||
group:
|
||||
name: Name
|
||||
roles: Roles
|
||||
user:
|
||||
email: Email
|
||||
enabled: Enabled
|
||||
password:
|
||||
label: Password
|
||||
confirmation: Verification
|
||||
remember_me: Remember me
|
||||
shipping_address: Shipping address
|
||||
customer:
|
||||
first_name: First name
|
||||
groups: Groups
|
||||
last_name: Last name
|
||||
email: Email
|
||||
phone_number: Phone number
|
||||
gender: Gender
|
||||
birthday: Birthday
|
||||
billing_address: Billing address
|
||||
different_billing_address: Use different address for billing?
|
||||
only_customer_registration: Create account?
|
||||
user_filter:
|
||||
query: Search
|
||||
user_change_password:
|
||||
confirmation: Confirmation
|
||||
current: Current password
|
||||
new: New password
|
||||
user_reset_password:
|
||||
confirmation: Confirmation
|
||||
new: New password
|
||||
gender:
|
||||
unknown: Unknown
|
||||
male: Male
|
||||
female: Female
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
sylius:
|
||||
group:
|
||||
name:
|
||||
max: Group name must not be longer than {{ limit }} characters.
|
||||
min: Group name must be at least {{ limit }} characters long.
|
||||
not_blank: Please enter group name.
|
||||
|
||||
user:
|
||||
email:
|
||||
not_blank: Please enter your email.
|
||||
invalid: This email is invalid.
|
||||
not_registered: User with this email does not exist. Please register first.
|
||||
plainPassword:
|
||||
not_blank: Please enter your password.
|
||||
mismatch: The entered passwords don't match
|
||||
wrong_current: Provided password is different than the current one.
|
||||
password:
|
||||
min: Password must be at least {{ limit }} characters long.
|
||||
max: Password must not be longer than {{ limit }} characters.
|
||||
|
||||
customer:
|
||||
first_name:
|
||||
max: First name must not be longer than {{ limit }} characters.
|
||||
min: First name must be at least {{ limit }} characters long.
|
||||
not_blank: Please enter your first name.
|
||||
last_name:
|
||||
max: Last name must not be longer than {{ limit }} characters.
|
||||
min: Last name must be at least {{ limit }} characters long.
|
||||
not_blank: Please enter your last name.
|
||||
gender:
|
||||
not_blank: Please choose your gender.
|
||||
email:
|
||||
already_used: This email is already used, please login or use forgotten password.
|
||||
max: Email must not be longer than {{ limit }} characters.
|
||||
min: Email must be at least {{ limit }} characters long.
|
||||
not_blank: Please enter your email.
|
||||
invalid: This email is invalid.
|
||||
unique: This email is already used.
|
||||
registered: This email is already registered, please login or use forgotten password.
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
{% extends 'SyliusUserBundle::layout.html.twig' %}
|
||||
{% extends 'SyliusCustomerBundle::layout.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<strong>{{ customer.fullName|upper }}</strong><br>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
{% extends 'SyliusUserBundle::layout.html.twig' %}
|
||||
{% extends 'SyliusCustomerBundle::layout.html.twig' %}
|
||||
{% from 'SyliusResourceBundle:Macros:actions.html.twig' import update %}
|
||||
|
||||
{% block content %}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
|
||||
{{ 'sylius.ui.logged_in_as'|trans({'%username%': app.user.username}) }}
|
||||
<a href="{{ path('sylius_user_security_logout') }}">
|
||||
{{ 'sylius.ui.logout'|trans }}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="{{ path('sylius_user_security_login') }}">{{ 'sylius.ui.login'|trans }}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% block flashes %}
|
||||
{% if app.request.hasPreviousSession %}
|
||||
{% for type, messages in app.session.flashbag.all() %}
|
||||
{% for message in messages %}
|
||||
<div class="flash-{{ type }}">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock flashes %}
|
||||
|
||||
<div>
|
||||
{% block content %}
|
||||
{% endblock content %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
39
src/Sylius/Bundle/CustomerBundle/SyliusCustomerBundle.php
Normal file
39
src/Sylius/Bundle/CustomerBundle/SyliusCustomerBundle.php
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CustomerBundle;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\AbstractResourceBundle;
|
||||
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
|
||||
|
||||
/**
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
*/
|
||||
class SyliusCustomerBundle extends AbstractResourceBundle
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getSupportedDrivers()
|
||||
{
|
||||
return [
|
||||
SyliusResourceBundle::DRIVER_DOCTRINE_ORM,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getModelNamespace()
|
||||
{
|
||||
return 'Sylius\Component\Customer\Model';
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Validator\Initializer;
|
||||
namespace Sylius\Bundle\CustomerBundle\Validator\Initializer;
|
||||
|
||||
use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
68
src/Sylius/Bundle/CustomerBundle/composer.json
Normal file
68
src/Sylius/Bundle/CustomerBundle/composer.json
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"name": "sylius/customer-bundle",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Customers management for Symfony2 projects.",
|
||||
"keywords": ["customer", "groups"],
|
||||
"homepage": "http://sylius.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paweł Jędrzejewski",
|
||||
"homepage": "http://pjedrzejewski.com"
|
||||
},
|
||||
{
|
||||
"name": "Michał Marcinkowski",
|
||||
"email": "michal.marcinkowski@lakion.com"
|
||||
},
|
||||
{
|
||||
"name": "Łukasz Chruściel",
|
||||
"email": "lukasz.chrusciel@lakion.com"
|
||||
},
|
||||
{
|
||||
"name": "Bartosz Siejka",
|
||||
"homepage": "http://bsiejka.com"
|
||||
},
|
||||
{
|
||||
"name": "Sylius project",
|
||||
"homepage": "http://sylius.org"
|
||||
},
|
||||
{
|
||||
"name": "Community contributions",
|
||||
"homepage": "http://github.com/Sylius/Sylius/contributors"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^5.6|^7.0",
|
||||
|
||||
"sylius/customer": "^1.0",
|
||||
"sylius/resource-bundle": "^1.0",
|
||||
"symfony/framework-bundle": "^2.8",
|
||||
"webmozart/assert": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^2.4",
|
||||
"symfony/form": "^2.8"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Sylius\\Bundle\\CustomerBundle\\": "" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Sylius\\Bundle\\CustomerBundle\\spec\\": "spec/" }
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true,
|
||||
"repositories": [
|
||||
{
|
||||
"type": "path",
|
||||
"url": "../../*/*"
|
||||
}
|
||||
],
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
5
src/Sylius/Bundle/CustomerBundle/phpspec.yml.dist
Normal file
5
src/Sylius/Bundle/CustomerBundle/phpspec.yml.dist
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
suites:
|
||||
main:
|
||||
namespace: Sylius\Bundle\CustomerBundle
|
||||
psr4_prefix: Sylius\Bundle\CustomerBundle
|
||||
src_path: .
|
||||
|
|
@ -9,16 +9,20 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Doctrine\ORM;
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Doctrine\ORM;
|
||||
|
||||
use Doctrine\ORM\AbstractQuery;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Doctrine\ORM\Mapping\ClassMetadata;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\ORM\Query\FilterCollection;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
|
||||
final class GroupRepositorySpec extends ObjectBehavior
|
||||
class CustomerRepositorySpec extends ObjectBehavior
|
||||
{
|
||||
public function let(EntityManager $em, ClassMetadata $classMetadata)
|
||||
{
|
||||
|
|
@ -27,7 +31,7 @@ final class GroupRepositorySpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Doctrine\ORM\GroupRepository');
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Doctrine\ORM\CustomerRepository');
|
||||
}
|
||||
|
||||
function it_is_a_repository()
|
||||
|
|
@ -35,12 +39,19 @@ final class GroupRepositorySpec extends ObjectBehavior
|
|||
$this->shouldHaveType(EntityRepository::class);
|
||||
}
|
||||
|
||||
function it_has_a_form_query_builder($em, QueryBuilder $builder)
|
||||
function it_finds_details($em, QueryBuilder $builder, Expr $expr, AbstractQuery $query)
|
||||
{
|
||||
$builder->expr()->shouldBeCalled()->willReturn($expr);
|
||||
$expr->eq('o.id', ':id')->shouldBeCalled()->willReturn($expr);
|
||||
|
||||
$em->createQueryBuilder()->shouldBeCalled()->willReturn($builder);
|
||||
$builder->select('o')->shouldBeCalled()->willReturn($builder);
|
||||
$builder->from(Argument::any(), 'o', Argument::cetera())->shouldBeCalled();
|
||||
$builder->from(Argument::any(), 'o', Argument::cetera())->shouldBeCalled()->willReturn($builder);
|
||||
$builder->andWhere($expr)->shouldBeCalled()->willReturn($builder);
|
||||
$builder->setParameter('id', 1)->shouldBeCalled()->willReturn($builder);
|
||||
$builder->getQuery()->shouldBeCalled()->willReturn($query);
|
||||
$query->getOneOrNullResult()->shouldBeCalled();
|
||||
|
||||
$this->getFormQueryBuilder();
|
||||
$this->findForDetailsPage(1);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Form\EventSubscriber;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
use Sylius\Component\User\Model\UserInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\Form\Form;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
|
||||
/**
|
||||
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
|
||||
*/
|
||||
class AddUserFormSubscriberSpec extends ObjectBehavior
|
||||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Form\EventSubscriber\AddUserFormSubscriber');
|
||||
}
|
||||
|
||||
function it_is_event_subscriber_instance()
|
||||
{
|
||||
$this->shouldImplement(EventSubscriberInterface::class);
|
||||
}
|
||||
|
||||
function it_adds_user_form_type_and_create_user_check(
|
||||
FormEvent $event,
|
||||
Form $form
|
||||
) {
|
||||
$event->getForm()->willReturn($form);
|
||||
|
||||
$form->add('user', 'sylius_user')->shouldBeCalled();
|
||||
|
||||
$this->preSetData($event);
|
||||
}
|
||||
|
||||
function it_removes_user_form_type_by_default(
|
||||
FormEvent $event,
|
||||
Form $form,
|
||||
CustomerInterface $customer
|
||||
) {
|
||||
$event->getData()->willReturn([], ['user' => ['plainPassword' => '']]);
|
||||
$event->getForm()->willReturn($form);
|
||||
$form->getNormData()->willReturn($customer);
|
||||
$customer->getUser()->willReturn(null);
|
||||
|
||||
$event->setData([])->shouldBeCalledTimes(1);
|
||||
$form->remove('user')->shouldBeCalledTimes(2);
|
||||
|
||||
$this->preSubmit($event);
|
||||
$this->preSubmit($event);
|
||||
}
|
||||
|
||||
function it_does_not_remove_user_form_type_if_users_data_is_submitted_and_user_data_is_created(
|
||||
FormEvent $event,
|
||||
Form $form,
|
||||
CustomerInterface $customer,
|
||||
UserInterface $user
|
||||
) {
|
||||
$event->getData()->willReturn(['user' => ['plainPassword' => 'test']]);
|
||||
$event->getForm()->willReturn($form);
|
||||
$form->getNormData()->willReturn($customer);
|
||||
$customer->getUser()->willReturn($user);
|
||||
|
||||
$form->remove('user')->shouldNotBeCalled();
|
||||
|
||||
$this->preSubmit($event);
|
||||
}
|
||||
|
||||
function it_remove_user_form_type_if_users_data_is_not_submitted_and_user_is_not_created(
|
||||
FormEvent $event,
|
||||
Form $form,
|
||||
CustomerInterface $customer
|
||||
) {
|
||||
$event->getData()->willReturn(['user' => ['plainPassword' => '']]);
|
||||
$event->getForm()->willReturn($form);
|
||||
$form->getNormData()->willReturn($customer);
|
||||
$customer->getUser()->willReturn(null);
|
||||
|
||||
$event->setData([])->shouldBeCalled();
|
||||
$form->remove('user')->shouldBeCalled();
|
||||
|
||||
$this->preSubmit($event);
|
||||
}
|
||||
|
||||
function it_does_not_remove_user_form_type_if_users_data_is_submitted_and_user_is_not_created(
|
||||
FormEvent $event,
|
||||
Form $form,
|
||||
CustomerInterface $customer
|
||||
) {
|
||||
$event->getData()->willReturn(['user' => ['plainPassword' => 'test']]);
|
||||
$event->getForm()->willReturn($form);
|
||||
$form->getNormData()->willReturn($customer);
|
||||
$customer->getUser()->willReturn(null);
|
||||
|
||||
$form->remove('user')->shouldNotBeCalled();
|
||||
|
||||
$this->preSubmit($event);
|
||||
}
|
||||
|
||||
function it_does_not_remove_user_form_type_if_users_data_is_not_submitted_and_user_is_created(
|
||||
FormEvent $event,
|
||||
Form $form,
|
||||
CustomerInterface $customer,
|
||||
UserInterface $user
|
||||
) {
|
||||
$event->getData()->willReturn(['user' => ['plainPassword' => '']]);
|
||||
$event->getForm()->willReturn($form);
|
||||
$form->getNormData()->willReturn($customer);
|
||||
$customer->getUser()->willReturn($user);
|
||||
|
||||
$form->remove('user')->shouldNotBeCalled();
|
||||
|
||||
$this->preSubmit($event);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
|
@ -25,7 +25,7 @@ final class CustomerProfileTypeSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Form\Type\CustomerProfileType');
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Form\Type\CustomerProfileType');
|
||||
}
|
||||
|
||||
function it_is_a_form()
|
||||
|
|
@ -9,12 +9,12 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Sylius\Bundle\UserBundle\Form\EventSubscriber\CustomerRegistrationFormSubscriber;
|
||||
use Sylius\Bundle\CustomerBundle\Form\EventSubscriber\CustomerRegistrationFormSubscriber;
|
||||
use Sylius\Bundle\UserBundle\Form\EventSubscriber\UserRegistrationFormSubscriber;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
use Symfony\Component\Form\Test\FormBuilderInterface;
|
||||
|
|
@ -29,7 +29,7 @@ final class CustomerRegistrationTypeSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Form\Type\CustomerRegistrationType');
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Form\Type\CustomerRegistrationType');
|
||||
}
|
||||
|
||||
function it_is_a_form()
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
|
@ -30,7 +30,7 @@ final class CustomerTypeSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Form\Type\CustomerType');
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Form\Type\CustomerType');
|
||||
}
|
||||
|
||||
function it_extends_abstract_resource_type()
|
||||
|
|
@ -52,7 +52,6 @@ final class CustomerTypeSpec extends ObjectBehavior
|
|||
$builder->add('gender', 'sylius_gender', Argument::any())->shouldBeCalled()->willReturn($builder);
|
||||
$builder->add('phoneNumber', 'text', Argument::any())->shouldBeCalled()->willReturn($builder);
|
||||
$builder->add('groups', 'sylius_group_choice', Argument::any())->shouldBeCalled()->willReturn($builder);
|
||||
$builder->addEventSubscriber($addUserTypeSubscriber)->shouldBeCalled()->willReturn($builder);
|
||||
|
||||
$this->buildForm($builder, []);
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
|
|
@ -20,7 +20,7 @@ final class GenderTypeSpec extends ObjectBehavior
|
|||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Form\Type\GenderType');
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Form\Type\GenderType');
|
||||
}
|
||||
|
||||
function it_is_a_form()
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Form\Type;
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Form\Type;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
|
@ -25,7 +25,7 @@ final class GroupTypeSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Form\Type\GroupType');
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Form\Type\GroupType');
|
||||
}
|
||||
|
||||
function it_is_a_form()
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\UserBundle\Validator\Initializer;
|
||||
namespace spec\Sylius\Bundle\CustomerBundle\Validator\Initializer;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
|
|
@ -29,7 +29,7 @@ final class CustomerInitializerSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\Validator\Initializer\CustomerInitializer');
|
||||
$this->shouldHaveType('Sylius\Bundle\CustomerBundle\Validator\Initializer\CustomerInitializer');
|
||||
}
|
||||
|
||||
function it_implements_symfony_validator_initializer_interface()
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
### v1.0.0-alpha.1
|
||||
|
||||
* Separate logic about customer to new bundle.
|
||||
|
||||
### v0.15.0
|
||||
|
||||
|
|
|
|||
|
|
@ -14,21 +14,10 @@ namespace Sylius\Bundle\UserBundle\DependencyInjection;
|
|||
use Sylius\Bundle\ResourceBundle\Controller\ResourceController;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceChoiceType;
|
||||
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
|
||||
use Sylius\Bundle\UserBundle\Controller\CustomerController;
|
||||
use Sylius\Bundle\UserBundle\Controller\UserController;
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\ResourceFromIdentifierType;
|
||||
use Sylius\Bundle\UserBundle\Form\Type\CustomerProfileType;
|
||||
use Sylius\Bundle\UserBundle\Form\Type\CustomerRegistrationType;
|
||||
use Sylius\Bundle\UserBundle\Form\Type\CustomerSimpleRegistrationType;
|
||||
use Sylius\Bundle\UserBundle\Form\Type\CustomerType;
|
||||
use Sylius\Bundle\UserBundle\Form\Type\GroupType;
|
||||
use Sylius\Bundle\UserBundle\Form\Type\UserRegistrationType;
|
||||
use Sylius\Bundle\UserBundle\Form\Type\UserType;
|
||||
use Sylius\Component\Resource\Factory\Factory;
|
||||
use Sylius\Component\Customer\Model\Customer;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
use Sylius\Component\Customer\Model\Group;
|
||||
use Sylius\Component\Customer\Model\GroupInterface;
|
||||
use Sylius\Component\User\Model\User;
|
||||
use Sylius\Component\User\Model\UserInterface;
|
||||
use Sylius\Component\User\Model\UserOAuth;
|
||||
|
|
@ -116,58 +105,6 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('resources')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('customer')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('templates')->defaultValue('SyliusUserBundle:Customer')->end()
|
||||
->variableNode('options')->end()
|
||||
->arrayNode('classes')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue(Customer::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('interface')->defaultValue(CustomerInterface::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('controller')->defaultValue(CustomerController::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('repository')->cannotBeEmpty()->end()
|
||||
->scalarNode('factory')->defaultValue(Factory::class)->end()
|
||||
->arrayNode('form')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('default')->defaultValue(CustomerType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('profile')->defaultValue(CustomerProfileType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('registration')->defaultValue(CustomerRegistrationType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('simple_registration')->defaultValue(CustomerSimpleRegistrationType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('validation_groups')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('default')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius'])
|
||||
->end()
|
||||
->arrayNode('profile')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius', 'sylius_customer_profile'])
|
||||
->end()
|
||||
->arrayNode('registration')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius', 'sylius_customer_profile', 'sylius_user_registration'])
|
||||
->end()
|
||||
->arrayNode('simple_registration')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius', 'sylius_user_registration'])
|
||||
->end()
|
||||
->arrayNode('guest')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius_customer_guest'])
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('user')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
|
|
@ -221,43 +158,6 @@ class Configuration implements ConfigurationInterface
|
|||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('group')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->variableNode('options')->end()
|
||||
->arrayNode('classes')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue(Group::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('interface')->defaultValue(GroupInterface::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('controller')->defaultValue(ResourceController::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('repository')->cannotBeEmpty()->end()
|
||||
->scalarNode('factory')->defaultValue(Factory::class)->end()
|
||||
->arrayNode('form')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('default')->defaultValue(GroupType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('choice')->defaultValue(ResourceChoiceType::class)->cannotBeEmpty()->end()
|
||||
->scalarNode('from_identifier')->defaultValue(ResourceFromIdentifierType::class)->cannotBeEmpty()->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('validation_groups')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('default')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius'])
|
||||
->end()
|
||||
->arrayNode('from_identifier')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(['sylius'])
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ use Symfony\Component\DependencyInjection\Reference;
|
|||
/**
|
||||
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
|
||||
*/
|
||||
class SyliusUserExtension extends AbstractResourceExtension implements PrependExtensionInterface
|
||||
class SyliusUserExtension extends AbstractResourceExtension
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -42,41 +42,5 @@ class SyliusUserExtension extends AbstractResourceExtension implements PrependEx
|
|||
$container->setParameter('sylius.user.resetting.token_length', $config['resetting']['token']['length']);
|
||||
$container->setParameter('sylius.user.resetting.pin_length', $config['resetting']['pin']['length']);
|
||||
$container->setParameter('sylius.user.verification.token_length', $config['verification']['token']['length']);
|
||||
|
||||
$container
|
||||
->getDefinition('sylius.form.type.customer_registration')
|
||||
->addArgument(new Reference('sylius.repository.customer'))
|
||||
;
|
||||
$container
|
||||
->getDefinition('sylius.form.type.customer_simple_registration')
|
||||
->addArgument(new Reference('sylius.repository.customer'))
|
||||
;
|
||||
$container
|
||||
->getDefinition('sylius.form.type.customer')
|
||||
->addArgument(new Reference('sylius.form.event_subscriber.add_user_type'))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
||||
$this->prependHwiOauth($container, $loader);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
* @param LoaderInterface $loader
|
||||
*/
|
||||
private function prependHwiOauth(ContainerBuilder $container, LoaderInterface $loader)
|
||||
{
|
||||
if (!$container->hasExtension('hwi_oauth')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$loader->load('integration/hwi_oauth.xml');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\UserBundle\Doctrine\ORM;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
use Sylius\Component\Customer\Repository\GroupRepositoryInterface;
|
||||
|
||||
/**
|
||||
* @author Antonio Perić <antonio@locastic.com>
|
||||
*/
|
||||
class GroupRepository extends EntityRepository implements GroupRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormQueryBuilder()
|
||||
{
|
||||
return $this->createQueryBuilder('o');
|
||||
}
|
||||
}
|
||||
|
|
@ -48,12 +48,7 @@ class UserProvider extends BaseUserProvider implements AccountConnectorInterface
|
|||
* @var FactoryInterface
|
||||
*/
|
||||
protected $customerFactory;
|
||||
|
||||
/**
|
||||
* @var RepositoryInterface
|
||||
*/
|
||||
protected $customerRepository;
|
||||
|
||||
|
||||
/**
|
||||
* @var FactoryInterface
|
||||
*/
|
||||
|
|
@ -66,7 +61,6 @@ class UserProvider extends BaseUserProvider implements AccountConnectorInterface
|
|||
|
||||
/**
|
||||
* @param FactoryInterface $customerFactory
|
||||
* @param RepositoryInterface $customerRepository
|
||||
* @param FactoryInterface $userFactory
|
||||
* @param UserRepositoryInterface $userRepository
|
||||
* @param FactoryInterface $oauthFactory
|
||||
|
|
@ -76,7 +70,6 @@ class UserProvider extends BaseUserProvider implements AccountConnectorInterface
|
|||
*/
|
||||
public function __construct(
|
||||
FactoryInterface $customerFactory,
|
||||
RepositoryInterface $customerRepository,
|
||||
FactoryInterface $userFactory,
|
||||
UserRepositoryInterface $userRepository,
|
||||
FactoryInterface $oauthFactory,
|
||||
|
|
@ -86,7 +79,6 @@ class UserProvider extends BaseUserProvider implements AccountConnectorInterface
|
|||
) {
|
||||
parent::__construct($userRepository, $canonicalizer);
|
||||
|
||||
$this->customerFactory = $customerFactory;
|
||||
$this->customerRepository = $customerRepository;
|
||||
$this->oauthFactory = $oauthFactory;
|
||||
$this->oauthRepository = $oauthRepository;
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@
|
|||
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius.repository.group.class">Sylius\Bundle\UserBundle\Doctrine\ORM\GroupRepository</parameter>
|
||||
<parameter key="sylius.repository.user.class">Sylius\Bundle\UserBundle\Doctrine\ORM\UserRepository</parameter>
|
||||
<parameter key="sylius.repository.customer.class">Sylius\Bundle\UserBundle\Doctrine\ORM\CustomerRepository</parameter>
|
||||
</parameters>
|
||||
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -40,27 +40,17 @@
|
|||
<parameter key="sylius.form.type.user_request_password_reset.class">Sylius\Bundle\UserBundle\Form\Type\UserRequestPasswordResetType</parameter>
|
||||
<parameter key="sylius.form.type.user_reset_password.class">Sylius\Bundle\UserBundle\Form\Type\UserResetPasswordType</parameter>
|
||||
<parameter key="sylius.form.type.user_change_password.class">Sylius\Bundle\UserBundle\Form\Type\UserChangePasswordType</parameter>
|
||||
<parameter key="sylius.form.type.gender.class">Sylius\Bundle\UserBundle\Form\Type\GenderType</parameter>
|
||||
|
||||
<parameter key="sylius.listener.default_username.class">Sylius\Bundle\UserBundle\EventListener\DefaultUsernameORMListener</parameter>
|
||||
<parameter key="sylius.listener.customer_aware.class">Sylius\Bundle\UserBundle\EventListener\CustomerAwareListener</parameter>
|
||||
<parameter key="sylius.listener.user_delete.class">Sylius\Bundle\UserBundle\EventListener\UserDeleteListener</parameter>
|
||||
<parameter key="sylius.listener.canonicalizer.class">Sylius\Bundle\UserBundle\EventListener\CanonicalizerListener</parameter>
|
||||
<parameter key="sylius.listener.password_updater.class">Sylius\Bundle\UserBundle\EventListener\PasswordUpdaterListener</parameter>
|
||||
<parameter key="sylius.listener.user_last_login.class">Sylius\Bundle\UserBundle\EventListener\UserLastLoginSubscriber</parameter>
|
||||
<parameter key="sylius.listener.user_auto_login.class">Sylius\Bundle\UserBundle\EventListener\UserAutoLoginListener</parameter>
|
||||
<parameter key="sylius.listener.user_reloader.class">Sylius\Bundle\UserBundle\EventListener\UserReloaderListener</parameter>
|
||||
<parameter key="sylius.listener.user_mailer_listener.class">Sylius\Bundle\UserBundle\EventListener\MailerListener</parameter>
|
||||
<parameter key="sylius.listener.user_registration.class">Sylius\Bundle\UserBundle\EventListener\UserRegistrationListener</parameter>
|
||||
|
||||
<parameter key="sylius.form.event_subscriber.add_user_type.class">Sylius\Bundle\UserBundle\Form\EventSubscriber\AddUserFormSubscriber</parameter>
|
||||
<parameter key="sylius.form.event_subscriber.set_customer_type.class">Sylius\Bundle\UserBundle\Form\EventSubscriber\SetCustomerFormSubscriber</parameter>
|
||||
|
||||
<parameter key="sylius.controller.user_security.class">Sylius\Bundle\UserBundle\Controller\SecurityController</parameter>
|
||||
|
||||
<parameter key="sylius.user.validator.unique_registered_user.class">Sylius\Bundle\UserBundle\Validator\Constraints\RegisteredUserValidator</parameter>
|
||||
<parameter key="sylius.user.validator.customer_initializer.class">Sylius\Bundle\UserBundle\Validator\Initializer\CustomerInitializer</parameter>
|
||||
|
||||
<parameter key="sylius.form.model.change_password.class">Sylius\Bundle\UserBundle\Form\Model\ChangePassword</parameter>
|
||||
</parameters>
|
||||
|
||||
|
|
@ -120,13 +110,6 @@
|
|||
<argument type="service" id="sylius.manager.user" />
|
||||
<tag name="kernel.event_subscriber" />
|
||||
</service>
|
||||
<service id="sylius.listener.default_username" class="%sylius.listener.default_username.class%">
|
||||
<tag name="doctrine.event_listener" event="onFlush" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_auto_login" class="%sylius.listener.user_auto_login.class%">
|
||||
<argument type="service" id="sylius.security.user_login" />
|
||||
<tag name="kernel.event_listener" event="sylius.customer.post_register" method="login" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_reloader" class="%sylius.listener.user_reloader.class%">
|
||||
<argument type="service" id="sylius.user.user_reloader" />
|
||||
<tag name="kernel.event_listener" event="sylius.user.post_create" method="reloadUser" />
|
||||
|
|
@ -197,20 +180,6 @@
|
|||
<service id="sylius.form.type.gender" class="%sylius.form.type.gender.class%">
|
||||
<tag name="form.type" alias="sylius_gender" />
|
||||
</service>
|
||||
|
||||
<!-- Form event subscribers-->
|
||||
<service id="sylius.form.event_subscriber.add_user_type" class="%sylius.form.event_subscriber.add_user_type.class%" />
|
||||
|
||||
<!-- Validators -->
|
||||
<service id="validator.unique.registered_user" class="%sylius.user.validator.unique_registered_user.class%">
|
||||
<argument type="service" id="sylius.repository.customer" />
|
||||
<tag name="validator.constraint_validator" alias="registered_user_validator" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.user.validator.customer_initializer" class="%sylius.user.validator.customer_initializer.class%">
|
||||
<argument type="service" id="sylius.user.canonicalizer" />
|
||||
<tag name="validator.initializer" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -16,77 +16,6 @@
|
|||
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
|
||||
http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
|
||||
|
||||
<class name="Sylius\Component\Customer\Model\Customer">
|
||||
<constraint name="Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity">
|
||||
<option name="message">sylius.customer.email.unique</option>
|
||||
<option name="fields">emailCanonical</option>
|
||||
<option name="errorPath">email</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Sylius\Bundle\UserBundle\Validator\Constraints\RegisteredUser">
|
||||
<option name="message">sylius.customer.email.registered</option>
|
||||
<option name="groups">sylius_customer_guest</option>
|
||||
</constraint>
|
||||
<property name="firstName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.first_name.not_blank</option>
|
||||
<option name="groups">sylius_customer_profile</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.customer.first_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.customer.first_name.max</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="lastName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.last_name.not_blank</option>
|
||||
<option name="groups">sylius_customer_profile</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.customer.last_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.customer.last_name.max</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="gender">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.gender.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="email">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.customer.email.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
<value>sylius_customer_guest</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.customer.email.min</option>
|
||||
<option name="max">254</option>
|
||||
<option name="maxMessage">sylius.customer.email.max</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
<value>sylius_customer_guest</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Email">
|
||||
<option name="message">sylius.customer.email.invalid</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
<value>sylius_customer_guest</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Component\User\Model\User">
|
||||
<property name="plainPassword">
|
||||
<constraint name="NotBlank">
|
||||
|
|
@ -172,20 +101,4 @@
|
|||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Component\Customer\Model\Group">
|
||||
<property name="name">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.group.name.not_blank</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.group.name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.group.name.max</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
</constraint-mapping>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
Sylius\Component\User\Model\User:
|
||||
exclusion_policy: ALL
|
||||
xml_root_name: sylius_user
|
||||
properties:
|
||||
id:
|
||||
expose: true
|
||||
type: integer
|
||||
groups: [Default, Detailed]
|
||||
username:
|
||||
expose: true
|
||||
type: string
|
||||
groups: [Default, Detailed, Secured]
|
||||
usernameCanonical:
|
||||
expose: true
|
||||
type: string
|
||||
groups: [Detailed]
|
||||
enabled:
|
||||
expose: true
|
||||
type: boolean
|
||||
groups: [Default, Detailed]
|
||||
roles:
|
||||
expose: true
|
||||
type: array
|
||||
groups: [Detailed]
|
||||
|
|
@ -17,7 +17,6 @@ use HWI\Bundle\OAuthBundle\OAuth\ResourceOwnerInterface;
|
|||
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
|
||||
use HWI\Bundle\OAuthBundle\Security\Core\User\OAuthAwareUserProviderInterface;
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Bundle\UserBundle\Doctrine\ORM\CustomerRepository;
|
||||
use Sylius\Component\Resource\Factory\FactoryInterface;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
use Sylius\Component\User\Canonicalizer\CanonicalizerInterface;
|
||||
|
|
@ -30,7 +29,6 @@ final class UserProviderSpec extends ObjectBehavior
|
|||
{
|
||||
function let(
|
||||
FactoryInterface $customerFactory,
|
||||
CustomerRepository $customerRepository,
|
||||
FactoryInterface $userFactory,
|
||||
UserRepositoryInterface $userRepository,
|
||||
FactoryInterface $oauthFactory,
|
||||
|
|
@ -38,7 +36,7 @@ final class UserProviderSpec extends ObjectBehavior
|
|||
ObjectManager $userManager,
|
||||
CanonicalizerInterface $canonicalizer
|
||||
) {
|
||||
$this->beConstructedWith($customerFactory, $customerRepository, $userFactory, $userRepository, $oauthFactory, $oauthRepository, $userManager, $canonicalizer);
|
||||
$this->beConstructedWith($customerFactory, $userFactory, $userRepository, $oauthFactory, $oauthRepository, $userManager, $canonicalizer);
|
||||
}
|
||||
|
||||
function it_is_initializable()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Component\Core\Repository;
|
||||
|
||||
use Pagerfanta\Pagerfanta;
|
||||
|
||||
/**
|
||||
* @author Anna Walasek <anna.walasek@lakion.com>
|
||||
*/
|
||||
interface CustomerRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @param array $criteria
|
||||
* @param array $sorting
|
||||
*
|
||||
* @return Pagerfanta
|
||||
*/
|
||||
public function createFilterPaginator(array $criteria = null, array $sorting = null);
|
||||
}
|
||||
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
namespace Sylius\Component\Customer\Repository;
|
||||
|
||||
use Pagerfanta\Pagerfanta;
|
||||
use Sylius\Component\Core\Model\CustomerInterface;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
|
||||
|
|
@ -38,12 +37,4 @@ interface CustomerRepositoryInterface extends RepositoryInterface
|
|||
* @return null|CustomerInterface
|
||||
*/
|
||||
public function findForDetailsPage($id);
|
||||
|
||||
/**
|
||||
* @param array $criteria
|
||||
* @param array $sorting
|
||||
*
|
||||
* @return Pagerfanta
|
||||
*/
|
||||
public function createFilterPaginator(array $criteria = null, array $sorting = null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Paweł Jędrzejewski
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Component\Customer\Repository;
|
||||
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Sylius\Component\Resource\Repository\RepositoryInterface;
|
||||
|
||||
/**
|
||||
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
|
||||
*/
|
||||
interface GroupRepositoryInterface extends RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* @return QueryBuilder
|
||||
*/
|
||||
public function getFormQueryBuilder();
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue