mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
Create user bundle
Cs fixer Add corrections - first review Add some user specs Fixed specs
This commit is contained in:
parent
b0ff37fd6b
commit
c7a25923c8
73 changed files with 992 additions and 245 deletions
|
|
@ -147,7 +147,7 @@ default:
|
|||
contexts:
|
||||
- Behat\MinkExtension\Context\MinkContext
|
||||
- Sylius\Bundle\CoreBundle\Behat\HookContext
|
||||
- Sylius\Bundle\CoreBundle\Behat\OAuthContext
|
||||
- Sylius\Bundle\UserBundle\Behat\OAuthContext
|
||||
- Sylius\Bundle\MoneyBundle\Behat\MoneyContext
|
||||
- Sylius\Bundle\ChannelBundle\Behat\ChannelContext
|
||||
- Sylius\Bundle\WebBundle\Behat\WebContext
|
||||
|
|
|
|||
|
|
@ -42,11 +42,9 @@ class FinalizeStep extends CheckoutStep
|
|||
{
|
||||
$order = $this->getCurrentCart();
|
||||
$this->dispatchCheckoutEvent(SyliusCheckoutEvents::FINALIZE_INITIALIZE, $order);
|
||||
|
||||
$order->setUser($this->getUser());
|
||||
|
||||
|
||||
$this->completeOrder($order);
|
||||
|
||||
|
||||
return $this->complete();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,29 +51,6 @@ class Configuration implements ConfigurationInterface
|
|||
->arrayNode('classes')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('user')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Component\Core\Model\User')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\Bundle\CoreBundle\Controller\UserController')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\Bundle\CoreBundle\Form\Type\UserType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('user_oauth')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Component\Core\Model\UserOAuth')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('group')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Component\Core\Model\Group')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\Bundle\CoreBundle\Form\Type\GroupType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('product_variant_image')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ class SyliusCoreExtension extends AbstractResourceExtension implements PrependEx
|
|||
'sylius_mailer',
|
||||
'sylius_taxation',
|
||||
'sylius_taxonomy',
|
||||
'sylius_user',
|
||||
'sylius_variation',
|
||||
'sylius_translation',
|
||||
'sylius_rbac',
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace Sylius\Bundle\CoreBundle\Form\Type\Rule;
|
|||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
use Sylius\Bundle\CoreBundle\Doctrine\ORM\GroupRepository;
|
||||
use Sylius\Bundle\UserBundle\Doctrine\ORM\GroupRepository;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Symfony\Component\Validator\Constraints\Type;
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ abstract class Kernel extends BaseKernel
|
|||
new \Sylius\Bundle\ContentBundle\SyliusContentBundle(),
|
||||
new \Sylius\Bundle\SearchBundle\SyliusSearchBundle(),
|
||||
new \Sylius\Bundle\RbacBundle\SyliusRbacBundle(),
|
||||
new \Sylius\Bundle\UserBundle\SyliusUserBundle(),
|
||||
|
||||
new \Sylius\Bundle\CoreBundle\SyliusCoreBundle(),
|
||||
new \Sylius\Bundle\WebBundle\SyliusWebBundle(),
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fos_user:
|
|||
firewall_name: main
|
||||
user_class: %sylius.model.user.class%
|
||||
group:
|
||||
group_class: Sylius\Component\Core\Model\Group
|
||||
group_class: %sylius.model.group.class%
|
||||
profile:
|
||||
form:
|
||||
type: sylius_user_profile
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ sylius_order:
|
|||
sylius_sequence:
|
||||
generators:
|
||||
%sylius.model.order.class%: sylius.sequence.sequential_number_generator
|
||||
|
||||
|
||||
sylius_pricing:
|
||||
forms:
|
||||
- sylius_product_variant
|
||||
|
|
@ -699,3 +699,8 @@ sylius_rbac:
|
|||
administrator: [catalog_manager, sales_manager, marketing_manager, accounts_manager, shipping_manager, content_editor, tax_manager, it, support]
|
||||
it: [security_auditor, developer]
|
||||
|
||||
sylius_user:
|
||||
classes:
|
||||
user:
|
||||
model: Sylius\Component\Core\Model\User
|
||||
controller: Sylius\Bundle\CoreBundle\Controller\UserController
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping">
|
||||
|
||||
<mapped-superclass name="Sylius\Component\Core\Model\Address" table="sylius_address">
|
||||
<many-to-one field="user" target-entity="Sylius\Component\Core\Model\UserInterface" inversed-by="addresses">
|
||||
<many-to-one field="user" target-entity="Sylius\Component\User\Model\UserInterface" inversed-by="addresses">
|
||||
<join-column name="user_id" referenced-column-name="id" nullable="true" on-delete="SET NULL"/>
|
||||
</many-to-one>
|
||||
</mapped-superclass>
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@
|
|||
</cascade>
|
||||
</one-to-many>
|
||||
|
||||
<many-to-one field="user" target-entity="Sylius\Component\Core\Model\UserInterface" inversed-by="orders">
|
||||
<many-to-one field="user" target-entity="Sylius\Component\User\Model\UserInterface" inversed-by="orders">
|
||||
<join-column name="user_id" referenced-column-name="id" nullable="true" />
|
||||
</many-to-one>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,21 +18,8 @@
|
|||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Sylius\Component\Core\Model\User" table="sylius_user">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<field name="currency" length="3" nullable="true" />
|
||||
<field name="firstName" column="first_name" type="string" nullable="true" />
|
||||
<field name="lastName" column="last_name" type="string" nullable="true" />
|
||||
<field name="createdAt" column="created_at" type="datetime">
|
||||
<gedmo:timestampable on="create"/>
|
||||
</field>
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
<field name="deletedAt" column="deleted_at" type="datetime" nullable="true" />
|
||||
|
||||
<one-to-one field="billingAddress" target-entity="Sylius\Component\Addressing\Model\AddressInterface">
|
||||
<join-column name="billing_address_id" on-delete="SET NULL" />
|
||||
<cascade>
|
||||
|
|
|
|||
|
|
@ -17,22 +17,7 @@
|
|||
http://symfony.com/schema/dic/services/services-1.0.xsd">
|
||||
|
||||
<parameters>
|
||||
<parameter key="sylius.repository.group.class">Sylius\Bundle\CoreBundle\Doctrine\ORM\GroupRepository</parameter>
|
||||
<parameter key="sylius.repository.user.class">Sylius\Bundle\CoreBundle\Doctrine\ORM\UserRepository</parameter>
|
||||
<parameter key="sylius.model.variant_image.class">Sylius\Component\Core\Model\VariantImage</parameter>
|
||||
<parameter key="sylius.form.type.user_choice.class">Sylius\Bundle\CoreBundle\Form\Type\UserEntityType</parameter>
|
||||
<parameter key="sylius.form.type.group_choice.class">Sylius\Bundle\CoreBundle\Form\Type\GroupEntityType</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.form.type.user_choice" class="%sylius.form.type.user_choice.class%">
|
||||
<argument>%sylius.model.user.class%</argument>
|
||||
<tag name="form.type" alias="sylius_user_choice" />
|
||||
</service>
|
||||
<service id="sylius.form.type.group_choice" class="%sylius.form.type.group_choice.class%">
|
||||
<argument>%sylius.model.group.class%</argument>
|
||||
<tag name="form.type" alias="sylius_group_choice" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
|||
|
|
@ -94,17 +94,6 @@
|
|||
<service id="sylius.form.type.list" class="%sylius.form.type.list.class%">
|
||||
<tag name="form.type" alias="list" />
|
||||
</service>
|
||||
<service id="sylius.form.type.user" class="%sylius.form.type.user.class%">
|
||||
<argument>%sylius.model.user.class%</argument>
|
||||
<tag name="form.type" alias="sylius_user" />
|
||||
</service>
|
||||
<service id="sylius.form.type.group" class="%sylius.form.type.group.class%">
|
||||
<argument>%sylius.model.group.class%</argument>
|
||||
<argument type="collection">
|
||||
<argument>sylius</argument>
|
||||
</argument>
|
||||
<tag name="form.type" alias="sylius_group" />
|
||||
</service>
|
||||
<service id="sylius.form.type.advanced_order" class="%sylius.form.type.advanced_order.class%">
|
||||
<argument>%sylius.model.order.class%</argument>
|
||||
<argument type="collection">
|
||||
|
|
|
|||
|
|
@ -48,9 +48,6 @@
|
|||
<parameter key="sylius.listener.order_pricing.class">Sylius\Bundle\CoreBundle\EventListener\OrderPricingListener</parameter>
|
||||
<parameter key="sylius.listener.order_shipping.class">Sylius\Bundle\CoreBundle\EventListener\OrderShippingListener</parameter>
|
||||
<parameter key="sylius.listener.order_taxation.class">Sylius\Bundle\CoreBundle\EventListener\OrderTaxationListener</parameter>
|
||||
<parameter key="sylius.listener.user_aware.class">Sylius\Bundle\CoreBundle\EventListener\UserAwareListener</parameter>
|
||||
<parameter key="sylius.listener.user_update.class">Sylius\Bundle\CoreBundle\EventListener\UserUpdateListener</parameter>
|
||||
<parameter key="sylius.listener.user_delete.class">Sylius\Bundle\CoreBundle\EventListener\UserDeleteListener</parameter>
|
||||
<parameter key="sylius.listener.restricted_zone.class">Sylius\Bundle\CoreBundle\EventListener\RestrictedZoneListener</parameter>
|
||||
<parameter key="sylius.listener.purchase.class">Sylius\Bundle\CoreBundle\EventListener\PurchaseListener</parameter>
|
||||
<parameter key="sylius.listener.checkout_addressing.class">Sylius\Bundle\CoreBundle\EventListener\CheckoutAddressingListener</parameter>
|
||||
|
|
@ -81,7 +78,7 @@
|
|||
<parameter key="sylius.price_calculator.channel_based.class">Sylius\Component\Core\Pricing\ChannelBasedCalculator</parameter>
|
||||
<parameter key="sylius.price_calculator.group_based.class">Sylius\Component\Core\Pricing\GroupBasedCalculator</parameter>
|
||||
<parameter key="sylius.price_calculator.zone_based.class">Sylius\Component\Core\Pricing\ZoneBasedCalculator</parameter>
|
||||
<parameter key="sylius.oauth.user_provider.class">Sylius\Bundle\CoreBundle\OAuth\UserProvider</parameter>
|
||||
<parameter key="sylius.oauth.user_provider.class">Sylius\Bundle\UserBundle\OAuth\UserProvider</parameter>
|
||||
<parameter key="sylius.data_collector.class">Sylius\Bundle\CoreBundle\DataCollector\SyliusDataCollector</parameter>
|
||||
<parameter key="sylius.dynamic_router.class">Symfony\Cmf\Component\Routing\DynamicRouter</parameter>
|
||||
<parameter key="sylius.generator.class">Sylius\Bundle\CoreBundle\Routing\SyliusAwareGenerator</parameter>
|
||||
|
|
@ -224,23 +221,6 @@
|
|||
</service>
|
||||
|
||||
<!-- listeners -->
|
||||
<service id="sylius.listener.user_update" class="%sylius.listener.user_update.class%">
|
||||
<argument type="service" id="fos_user.user_manager" />
|
||||
<tag name="kernel.event_listener" event="sylius.user.post_create" method="processUser" />
|
||||
<tag name="kernel.event_listener" event="sylius.user.post_update" method="processUser" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_delete" class="%sylius.listener.user_delete.class%">
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="router" />
|
||||
<argument type="service" id="session" />
|
||||
<argument>sylius_backend_user_index</argument>
|
||||
<tag name="kernel.event_listener" event="sylius.user.pre_delete" method="deleteUser" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_aware" class="%sylius.listener.user_aware.class%">
|
||||
<argument type="service" id="security.context" />
|
||||
<tag name="kernel.event_listener" event="sylius.checkout.security.pre_complete" method="setUser" priority="100" />
|
||||
<tag name="kernel.event_listener" event="sylius.cart.initialize" method="setUser" />
|
||||
</service>
|
||||
<service id="sylius.listener.order_inventory" class="%sylius.listener.order_inventory.class%">
|
||||
<argument type="service" id="sylius.order_processing.inventory_handler" />
|
||||
<tag name="kernel.event_listener" event="sylius.checkout.finalize.pre_complete" method="holdInventoryUnits" />
|
||||
|
|
@ -307,6 +287,11 @@
|
|||
<argument type="service" id="sylius.context.currency" />
|
||||
<tag name="kernel.event_listener" event="sylius.cart.initialize" method="processOrderCurrency" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_aware" class="%sylius.listener.user_aware.class%">
|
||||
<argument type="service" id="security.context" />
|
||||
<tag name="kernel.event_listener" event="sylius.checkout.security.pre_complete" method="setUser" priority="100" />
|
||||
<tag name="kernel.event_listener" event="sylius.cart.initialize" method="setUser" />
|
||||
</service>
|
||||
<service id="sylius.listener.restricted_zone" class="%sylius.listener.restricted_zone.class%">
|
||||
<argument type="service" id="sylius.checker.restricted_zone" />
|
||||
<argument type="service" id="sylius.cart_provider" />
|
||||
|
|
|
|||
|
|
@ -100,77 +100,7 @@
|
|||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Component\Core\Model\User">
|
||||
<property name="firstName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.user.first_name.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.user.first_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.user.first_name.max</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="lastName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.user.last_name.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.user.last_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.user.last_name.max</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="plainPassword">
|
||||
<constraint name="NotBlank">
|
||||
<option name="groups">
|
||||
<value>ProfileAdd</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Component\Core\Model\Group">
|
||||
<property name="name">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.group.name.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
</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">
|
||||
<value>sylius</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
|
||||
</class>
|
||||
<class name="Sylius\Component\Cart\Model\CartItem">
|
||||
<constraint name="Sylius\Bundle\InventoryBundle\Validator\Constraints\InStock">
|
||||
<option name="stockablePath">variant</option>
|
||||
|
|
|
|||
|
|
@ -1,22 +1,12 @@
|
|||
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.
|
||||
locale:
|
||||
code:
|
||||
not_blank: Please enter locale code.
|
||||
unique: This locale already exists.
|
||||
user:
|
||||
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.
|
||||
sylius_shipping:
|
||||
method:
|
||||
zone:
|
||||
not_blank: Please enter shipping method zone.
|
||||
product_variant:
|
||||
onHand:
|
||||
min: On hand must be greater than {{ limit }}.
|
||||
|
|
@ -27,11 +17,7 @@ sylius:
|
|||
product_translation:
|
||||
short_description:
|
||||
max: Short description must not be longer then {{ limit }} characters.
|
||||
|
||||
sylius_shipping:
|
||||
method:
|
||||
zone:
|
||||
not_blank: Please enter shipping method zone.
|
||||
|
||||
sylius_taxation:
|
||||
rate:
|
||||
zone:
|
||||
|
|
|
|||
|
|
@ -52,9 +52,6 @@ class SyliusCoreBundle extends AbstractResourceBundle
|
|||
protected function getModelInterfaces()
|
||||
{
|
||||
return array(
|
||||
'Sylius\Component\Core\Model\UserInterface' => 'sylius.model.user.class',
|
||||
'Sylius\Component\Core\Model\UserOAuthInterface' => 'sylius.model.user_oauth.class',
|
||||
'Sylius\Component\Core\Model\GroupInterface' => 'sylius.model.group.class',
|
||||
'Sylius\Component\Core\Model\ProductVariantImageInterface' => 'sylius.model.product_variant_image.class',
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ namespace Sylius\Bundle\FixturesBundle\DataFixtures\ORM;
|
|||
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
use Sylius\Bundle\FixturesBundle\DataFixtures\DataFixture;
|
||||
use Sylius\Component\Core\Model\GroupInterface;
|
||||
use Sylius\Component\User\Model\GroupInterface;
|
||||
|
||||
/**
|
||||
* Group fixtures.
|
||||
|
|
|
|||
5
src/Sylius/Bundle/UserBundle/.gitignore
vendored
Normal file
5
src/Sylius/Bundle/UserBundle/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
vendor/
|
||||
bin/
|
||||
|
||||
composer.phar
|
||||
composer.lock
|
||||
13
src/Sylius/Bundle/UserBundle/.travis.yml
Normal file
13
src/Sylius/Bundle/UserBundle/.travis.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
|
||||
before_script: composer install --prefer-source --no-interaction
|
||||
|
||||
script: bin/phpspec run -fpretty --verbose
|
||||
|
||||
notifications:
|
||||
irc: "irc.freenode.org#sylius-dev"
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Behat;
|
||||
namespace Sylius\Bundle\UserBundle\Behat;
|
||||
|
||||
use Behat\MinkExtension\Context\RawMinkContext;
|
||||
|
||||
6
src/Sylius/Bundle/UserBundle/CHANGELOG.md
Normal file
6
src/Sylius/Bundle/UserBundle/CHANGELOG.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
### v0.13.0
|
||||
|
||||
* Initial dev release.
|
||||
|
|
@ -0,0 +1,112 @@
|
|||
<?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\DependencyInjection;
|
||||
|
||||
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>
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('sylius_user');
|
||||
|
||||
$rootNode
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('driver')->cannotBeOverwritten()->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('currency_storage')->defaultValue('sylius.storage.session')->end()
|
||||
->end()
|
||||
;
|
||||
|
||||
$this->addValidationGroupsSection($rootNode);
|
||||
$this->addClassesSection($rootNode);
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `validation_groups` section.
|
||||
*
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addValidationGroupsSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('validation_groups')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('user')
|
||||
->prototype('scalar')->end()
|
||||
->defaultValue(array('sylius'))
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds `classes` section.
|
||||
*
|
||||
* @param ArrayNodeDefinition $node
|
||||
*/
|
||||
private function addClassesSection(ArrayNodeDefinition $node)
|
||||
{
|
||||
$node
|
||||
->children()
|
||||
->arrayNode('classes')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->arrayNode('user')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Component\User\Model\User')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\Bundle\UserBundle\Form\Type\UserType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('user_oauth')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Component\User\Model\UserOAuth')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
|
||||
->end()
|
||||
->end()
|
||||
->arrayNode('group')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
->scalarNode('model')->defaultValue('Sylius\Component\User\Model\Group')->end()
|
||||
->scalarNode('controller')->defaultValue('Sylius\Bundle\ResourceBundle\Controller\ResourceController')->end()
|
||||
->scalarNode('form')->defaultValue('Sylius\Bundle\UserBundle\Form\Type\GroupType')->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
<?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\DependencyInjection;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\DependencyInjection\AbstractResourceExtension;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
|
||||
/**
|
||||
* Locale extension.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@sylius.pl>
|
||||
*/
|
||||
class SyliusUserExtension extends AbstractResourceExtension
|
||||
{
|
||||
protected $configFiles = array(
|
||||
'services',
|
||||
'form',
|
||||
'templating',
|
||||
'twig',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function load(array $config, ContainerBuilder $container)
|
||||
{
|
||||
list($config) = $this->configure(
|
||||
$config,
|
||||
new Configuration(),
|
||||
$container,
|
||||
self::CONFIGURE_LOADER | self::CONFIGURE_DATABASE | self::CONFIGURE_PARAMETERS | self::CONFIGURE_VALIDATORS
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
|
||||
namespace Sylius\Bundle\UserBundle\Doctrine\ORM;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
|
||||
namespace Sylius\Bundle\UserBundle\Doctrine\ORM;
|
||||
|
||||
use Pagerfanta\PagerfantaInterface;
|
||||
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
|
||||
|
|
@ -9,10 +9,10 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\EventListener;
|
||||
namespace Sylius\Bundle\UserBundle\EventListener;
|
||||
|
||||
use Sylius\Component\Cart\Event\CartEvent;
|
||||
use Sylius\Component\Core\Model\UserAwareInterface;
|
||||
use Sylius\Component\User\Model\UserAwareInterface;
|
||||
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
use Symfony\Component\Security\Core\SecurityContextInterface;
|
||||
|
|
@ -35,7 +35,7 @@ class UserAwareListener
|
|||
}
|
||||
|
||||
if (!$resource instanceof UserAwareInterface) {
|
||||
throw new UnexpectedTypeException($resource, 'Sylius\Component\Core\Model\UserAwareInterface');
|
||||
throw new UnexpectedTypeException($resource, 'Sylius\Component\User\Model\UserAwareInterface');
|
||||
}
|
||||
|
||||
if (null === $user = $this->getUser()) {
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\EventListener;
|
||||
namespace Sylius\Bundle\UserBundle\EventListener;
|
||||
|
||||
use FOS\UserBundle\Model\UserInterface;
|
||||
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\EventListener;
|
||||
namespace Sylius\Bundle\UserBundle\EventListener;
|
||||
|
||||
use FOS\UserBundle\Model\UserInterface;
|
||||
use FOS\UserBundle\Model\UserManagerInterface;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type;
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
|
@ -46,7 +46,7 @@ abstract class GroupChoiceType extends AbstractType
|
|||
$resolver
|
||||
->setDefaults(array(
|
||||
'class' => $this->className,
|
||||
'property' => 'name'
|
||||
'property' => 'name',
|
||||
))
|
||||
;
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type;
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
|
||||
/**
|
||||
* Group choice form type.
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type;
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
@ -28,10 +28,9 @@ class GroupType extends AbstractResourceType
|
|||
{
|
||||
$builder
|
||||
->add('name', 'text', array(
|
||||
'label' => 'sylius.form.group.name'
|
||||
'label' => 'sylius.form.group.name',
|
||||
))
|
||||
;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
26
src/Sylius/Bundle/UserBundle/Form/Type/UserEntityType.php
Normal file
26
src/Sylius/Bundle/UserBundle/Form/Type/UserEntityType.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?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\Form\Type;
|
||||
|
||||
/**
|
||||
* User choice type for "doctrine/orm" driver.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
*/
|
||||
class UserEntityType extends UserChoiceType
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return 'entity';
|
||||
}
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\Form\Type;
|
||||
namespace Sylius\Bundle\UserBundle\Form\Type;
|
||||
|
||||
use FOS\UserBundle\Form\Type\ProfileFormType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
|
@ -36,10 +36,10 @@ class UserType extends ProfileFormType
|
|||
{
|
||||
$builder
|
||||
->add('firstName', 'text', array(
|
||||
'label' => 'sylius.form.user.first_name'
|
||||
'label' => 'sylius.form.user.first_name',
|
||||
))
|
||||
->add('lastName', 'text', array(
|
||||
'label' => 'sylius.form.user.last_name'
|
||||
'label' => 'sylius.form.user.last_name',
|
||||
))
|
||||
;
|
||||
|
||||
|
|
@ -47,15 +47,15 @@ class UserType extends ProfileFormType
|
|||
|
||||
$builder
|
||||
->add('plainPassword', 'password', array(
|
||||
'label' => 'sylius.form.user.password'
|
||||
'label' => 'sylius.form.user.password',
|
||||
))
|
||||
->add('enabled', 'checkbox', array(
|
||||
'label' => 'sylius.form.user.enabled'
|
||||
'label' => 'sylius.form.user.enabled',
|
||||
))
|
||||
->add('groups', 'sylius_group_choice', array(
|
||||
'label' => 'sylius.form.user.groups',
|
||||
'multiple' => true,
|
||||
'required' => false
|
||||
'required' => false,
|
||||
))
|
||||
->add('authorizationRoles', 'sylius_role_choice', array(
|
||||
'label' => 'sylius.form.user.roles',
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Bundle\CoreBundle\OAuth;
|
||||
namespace Sylius\Bundle\UserBundle\OAuth;
|
||||
|
||||
use FOS\UserBundle\Model\UserInterface as FOSUserInterface;
|
||||
use FOS\UserBundle\Model\UserManagerInterface;
|
||||
|
|
@ -53,7 +53,7 @@ class UserProvider extends FOSUBUserProvider
|
|||
{
|
||||
$oauth = $this->oauthRepository->findOneBy(array(
|
||||
'provider' => $response->getResourceOwner()->getName(),
|
||||
'identifier' => $response->getUsername()
|
||||
'identifier' => $response->getUsername(),
|
||||
));
|
||||
|
||||
if ($oauth instanceof UserOAuthInterface) {
|
||||
21
src/Sylius/Bundle/UserBundle/Provider/UserProvider.php
Normal file
21
src/Sylius/Bundle/UserBundle/Provider/UserProvider.php
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<?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\Provider;
|
||||
|
||||
use Sylius\Component\Locale\Provider\LocaleProvider as BaseLocaleProvider;
|
||||
|
||||
/**
|
||||
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
|
||||
*/
|
||||
class UserProvider extends BaseLocaleProvider implements LocaleProviderInterface
|
||||
{
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?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\Provider;
|
||||
|
||||
use Sylius\Component\Locale\Provider\LocaleProviderInterface as BaseLocaleProviderInterface;
|
||||
use A2lix\TranslationFormBundle\Locale\LocaleProviderInterface as FormLocaleProviderInterface;
|
||||
|
||||
/**
|
||||
* @author Gonzalo Vilaseca <gvilaseca@reiss.co.uk>
|
||||
*/
|
||||
interface UserProviderInterface extends BaseLocaleProviderInterface, FormLocaleProviderInterface
|
||||
{
|
||||
}
|
||||
75
src/Sylius/Bundle/UserBundle/README.md
Normal file
75
src/Sylius/Bundle/UserBundle/README.md
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
SyliusUserBundle [](http://travis-ci.org/Sylius/SyliusUserBundle)
|
||||
==================
|
||||
|
||||
[**Symfony2**](http://symfony.com) integration of Sylius User 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/SyliusUserBundle/index.html).
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
All informations about contributing to Sylius can be found on [this page](http://docs.sylius.org/en/latest/contributing/index.html).
|
||||
|
||||
Mailing lists
|
||||
-------------
|
||||
|
||||
### Users
|
||||
|
||||
Questions? Feel free to ask on [users mailing list](http://groups.google.com/group/sylius).
|
||||
|
||||
### Developers
|
||||
|
||||
To contribute and develop this bundle, use the [developers mailing list](http://groups.google.com/group/sylius-dev).
|
||||
|
||||
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/SyliusUserBundle/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/SyliusUserBundle/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/SyliusUserBundle/contributors).
|
||||
|
|
@ -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\Core\Model\Group" table="sylius_group">
|
||||
<mapped-superclass name="Sylius\Component\User\Model\Group" table="sylius_group">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?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.
|
||||
|
||||
-->
|
||||
|
||||
<doctrine-mongo-mapping xmlns="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
|
||||
xsi:schemaLocation="http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping
|
||||
http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping.xsd">
|
||||
|
||||
<mapped-superclass name="Sylius\Component\User\Model\User" collection="sylius_user">
|
||||
<field name="id" id="true" strategy="AUTO" />
|
||||
|
||||
<field fieldName="enabled" name="enabled" type="boolean" />
|
||||
|
||||
<field fieldName="createdAt" name="createdAt" type="date">
|
||||
<gedmo:timestampable on="create"/>
|
||||
</field>
|
||||
<field fieldName="updatedAt" name="updatedAt" type="date">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
|
||||
</mapped-superclass>
|
||||
</doctrine-mongo-mapping>
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
<?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.
|
||||
|
||||
-->
|
||||
|
||||
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
|
||||
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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\User" table="sylius_user">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
||||
<field name="firstName" column="first_name" type="string" nullable="true" />
|
||||
<field name="lastName" column="last_name" type="string" nullable="true" />
|
||||
<field name="createdAt" column="created_at" type="datetime">
|
||||
<gedmo:timestampable on="create"/>
|
||||
</field>
|
||||
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
|
||||
<gedmo:timestampable on="update"/>
|
||||
</field>
|
||||
<field name="deletedAt" column="deleted_at" type="datetime" nullable="true" />
|
||||
|
||||
<one-to-many field="oauthAccounts" target-entity="Sylius\Component\User\Model\UserOAuthInterface" mapped-by="user">
|
||||
<cascade>
|
||||
<cascade-all />
|
||||
</cascade>
|
||||
</one-to-many>
|
||||
|
||||
<many-to-many field="groups" target-entity="Sylius\Component\User\Model\GroupInterface">
|
||||
<cascade>
|
||||
<cascade-all />
|
||||
</cascade>
|
||||
<join-table name="sylius_user_group">
|
||||
<join-columns>
|
||||
<join-column name="user_id" referenced-column-name="id" on-delete="CASCADE"/>
|
||||
</join-columns>
|
||||
<inverse-join-columns>
|
||||
<join-column name="group_id" referenced-column-name="id" on-delete="CASCADE"/>
|
||||
</inverse-join-columns>
|
||||
</join-table>
|
||||
</many-to-many>
|
||||
|
||||
<gedmo:soft-deleteable field-name="deletedAt" />
|
||||
</mapped-superclass>
|
||||
|
||||
</doctrine-mapping>
|
||||
|
|
@ -16,7 +16,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\Core\Model\UserOAuth" table="sylius_user_oauth">
|
||||
<mapped-superclass name="Sylius\Component\User\Model\UserOAuth" table="sylius_user_oauth">
|
||||
<id name="id" column="id" type="integer">
|
||||
<generator strategy="AUTO" />
|
||||
</id>
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
<field name="identifier" type="string" />
|
||||
<field name="accessToken" column="access_token" type="string" nullable="true" />
|
||||
|
||||
<many-to-one field="user" target-entity="Sylius\Component\Core\Model\UserInterface" inversed-by="oauthAccounts">
|
||||
<many-to-one field="user" target-entity="Sylius\Component\User\Model\UserInterface" inversed-by="oauthAccounts">
|
||||
<join-column name="user_id" referenced-column-name="id" />
|
||||
</many-to-one>
|
||||
</mapped-superclass>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?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.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.form.type.user_choice.class">Sylius\Bundle\UserBundle\Form\Type\UserEntityType</parameter>
|
||||
<parameter key="sylius.form.type.group_choice.class">Sylius\Bundle\UserBundle\Form\Type\GroupEntityType</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.form.type.group_choice" class="%sylius.form.type.group_choice.class%">
|
||||
<argument>%sylius.model.group.class%</argument>
|
||||
<tag name="form.type" alias="sylius_group_choice" />
|
||||
</service>
|
||||
<service id="sylius.form.type.user_choice" class="%sylius.form.type.user_choice.class%">
|
||||
<argument>%sylius.model.user.class%</argument>
|
||||
<tag name="form.type" alias="sylius_user_choice" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
55
src/Sylius/Bundle/UserBundle/Resources/config/services.xml
Normal file
55
src/Sylius/Bundle/UserBundle/Resources/config/services.xml
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<?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.user_provider.class">Sylius\Bundle\UserBundle\Provider\UserProvider</parameter>
|
||||
<parameter key="sylius.listener.user_update.class">Sylius\Bundle\UserBundle\EventListener\UserUpdateListener</parameter>
|
||||
<parameter key="sylius.listener.user_delete.class">Sylius\Bundle\UserBundle\EventListener\UserDeleteListener</parameter>
|
||||
<parameter key="sylius.listener.user_aware.class">Sylius\Bundle\UserBundle\EventListener\UserAwareListener</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.listener.user_aware" class="%sylius.listener.user_aware.class%">
|
||||
<argument type="service" id="security.context" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_update" class="%sylius.listener.user_update.class%">
|
||||
<argument type="service" id="fos_user.user_manager" />
|
||||
<tag name="kernel.event_listener" event="sylius.user.post_create" method="processUser" />
|
||||
<tag name="kernel.event_listener" event="sylius.user.post_update" method="processUser" />
|
||||
</service>
|
||||
<service id="sylius.listener.user_delete" class="%sylius.listener.user_delete.class%">
|
||||
<argument type="service" id="security.context" />
|
||||
<argument type="service" id="router" />
|
||||
<argument type="service" id="session" />
|
||||
<argument>sylius_backend_user_index</argument>
|
||||
<tag name="kernel.event_listener" event="sylius.user.pre_delete" method="deleteUser" />
|
||||
</service>
|
||||
<service id="sylius.form.type.user" class="%sylius.form.type.user.class%">
|
||||
<argument>%sylius.model.user.class%</argument>
|
||||
<tag name="form.type" alias="sylius_user" />
|
||||
</service>
|
||||
<service id="sylius.form.type.group" class="%sylius.form.type.group.class%">
|
||||
<argument>%sylius.model.group.class%</argument>
|
||||
<argument type="collection">
|
||||
<argument>sylius</argument>
|
||||
</argument>
|
||||
<tag name="form.type" alias="sylius_group" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
30
src/Sylius/Bundle/UserBundle/Resources/config/twig.xml
Normal file
30
src/Sylius/Bundle/UserBundle/Resources/config/twig.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?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.twig.extension.user.class">Sylius\Bundle\UserBundle\Twig\UserExtension</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="sylius.twig.extension.locale" class="%sylius.twig.extension.locale.class%" public="false">
|
||||
<argument type="service" id="sylius.templating.helper.locale" />
|
||||
<tag name="twig.extension" />
|
||||
</service>
|
||||
</services>
|
||||
|
||||
</container>
|
||||
87
src/Sylius/Bundle/UserBundle/Resources/config/validation.xml
Normal file
87
src/Sylius/Bundle/UserBundle/Resources/config/validation.xml
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?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\User\Model\User">
|
||||
<property name="firstName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.user.first_name.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.user.first_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.user.first_name.max</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="lastName">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.user.last_name.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
<constraint name="Length">
|
||||
<option name="min">2</option>
|
||||
<option name="minMessage">sylius.user.last_name.min</option>
|
||||
<option name="max">255</option>
|
||||
<option name="maxMessage">sylius.user.last_name.max</option>
|
||||
<option name="groups">
|
||||
<value>Profile</value>
|
||||
<value>Registration</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
<property name="plainPassword">
|
||||
<constraint name="NotBlank">
|
||||
<option name="groups">
|
||||
<value>ProfileAdd</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
<class name="Sylius\Component\User\Model\Group">
|
||||
<property name="name">
|
||||
<constraint name="NotBlank">
|
||||
<option name="message">sylius.group.name.not_blank</option>
|
||||
<option name="groups">
|
||||
<value>sylius</value>
|
||||
</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">
|
||||
<value>sylius</value>
|
||||
</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
|
||||
</constraint-mapping>
|
||||
19
src/Sylius/Bundle/UserBundle/Resources/meta/LICENSE
Normal file
19
src/Sylius/Bundle/UserBundle/Resources/meta/LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2011-2015 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,16 @@
|
|||
sylius:
|
||||
form:
|
||||
group:
|
||||
name: Name
|
||||
roles: Roles
|
||||
user:
|
||||
billing_address: Billing address
|
||||
different_billing_address: Use different address for billing?
|
||||
enabled: Enabled
|
||||
first_name: First name
|
||||
groups: Groups
|
||||
last_name: Last name
|
||||
password: Password
|
||||
shipping_address: Shipping address
|
||||
user_filter:
|
||||
query: Search
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
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:
|
||||
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.
|
||||
53
src/Sylius/Bundle/UserBundle/SyliusUserBundle.php
Normal file
53
src/Sylius/Bundle/UserBundle/SyliusUserBundle.php
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<?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;
|
||||
|
||||
use Sylius\Bundle\ResourceBundle\AbstractResourceBundle;
|
||||
use Sylius\Bundle\ResourceBundle\SyliusResourceBundle;
|
||||
|
||||
/**
|
||||
* User bundle.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@sylius.pl>
|
||||
*/
|
||||
class SyliusUserBundle extends AbstractResourceBundle
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSupportedDrivers()
|
||||
{
|
||||
return array(
|
||||
SyliusResourceBundle::DRIVER_DOCTRINE_ORM,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getModelInterfaces()
|
||||
{
|
||||
return array(
|
||||
'Sylius\Component\User\Model\UserInterface' => 'sylius.model.user.class',
|
||||
'Sylius\Component\User\Model\UserOAuthInterface' => 'sylius.model.user_oauth.class',
|
||||
'Sylius\Component\User\Model\GroupInterface' => 'sylius.model.group.class',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getModelNamespace()
|
||||
{
|
||||
return 'Sylius\Component\User\Model';
|
||||
}
|
||||
}
|
||||
63
src/Sylius/Bundle/UserBundle/Twig/LocaleExtension.php
Normal file
63
src/Sylius/Bundle/UserBundle/Twig/LocaleExtension.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?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\Twig;
|
||||
|
||||
use Sylius\Bundle\LocaleBundle\Templating\Helper\LocaleHelper;
|
||||
|
||||
/**
|
||||
* Sylius locale Twig helper.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pjedrzejewski@diweb.pl>
|
||||
*/
|
||||
class UserExtension extends \Twig_Extension
|
||||
{
|
||||
/**
|
||||
* @var LocaleHelper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
/**
|
||||
* @param LocaleHelper $helper
|
||||
*/
|
||||
public function __construct(LocaleHelper $helper)
|
||||
{
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
new \Twig_SimpleFunction('sylius_locale', array($this, 'getLocale')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currently selected locale code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->helper->getLocale();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'sylius_locale';
|
||||
}
|
||||
}
|
||||
52
src/Sylius/Bundle/UserBundle/composer.json
Normal file
52
src/Sylius/Bundle/UserBundle/composer.json
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"name": "sylius/user-bundle",
|
||||
"type": "symfony-bundle",
|
||||
"description": "Users management for Symfony2 projects.",
|
||||
"keywords": ["user", "registration", "login", "groups"],
|
||||
"homepage": "http://sylius.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paweł Jędrzejewski",
|
||||
"homepage": "http://pjedrzejewski.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.3.3",
|
||||
|
||||
"sylius/user": "0.13.*@dev",
|
||||
"sylius/resource-bundle": "0.13.*@dev",
|
||||
"symfony/framework-bundle": "~2.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "~2.1",
|
||||
"symfony/form": "~2.3",
|
||||
"twig/twig": "~1.0"
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Sylius\\Bundle\\UserBundle\\": "" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Sylius\\Bundle\\UserBundle\\spec\\": "spec/" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.13-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
5
src/Sylius/Bundle/UserBundle/phpspec.yml
Normal file
5
src/Sylius/Bundle/UserBundle/phpspec.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
suites:
|
||||
main:
|
||||
namespace: Sylius\Bundle\UserBundle
|
||||
psr4_prefix: Sylius\Bundle\UserBundle
|
||||
src_path: .
|
||||
|
|
@ -9,11 +9,11 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\CoreBundle\EventListener;
|
||||
namespace spec\Sylius\Bundle\UserBundle\EventListener;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Prophecy\Argument;
|
||||
use Sylius\Component\Core\Model\UserAwareInterface;
|
||||
use Sylius\Component\User\Model\UserAwareInterface;
|
||||
use Sylius\Component\Core\Model\UserInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
|
@ -23,7 +23,7 @@ class UserAwareListenerSpec extends ObjectBehavior
|
|||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\CoreBundle\EventListener\UserAwareListener');
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\EventListener\UserAwareListener');
|
||||
}
|
||||
|
||||
function let(SecurityContextInterface $securityContext)
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\CoreBundle\EventListener;
|
||||
namespace spec\Sylius\Bundle\UserBundle\EventListener;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use FOS\UserBundle\Model\UserManagerInterface;
|
||||
|
|
@ -36,7 +36,7 @@ class UserDeleteListenerSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\CoreBundle\EventListener\UserDeleteListener');
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\EventListener\UserDeleteListener');
|
||||
}
|
||||
|
||||
function it_delete_user($event, $userInterface, $flashBag, $securityContext, TokenInterface $tokenInterface)
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Bundle\CoreBundle\OAuth;
|
||||
namespace spec\Sylius\Bundle\UserBundle\OAuth;
|
||||
|
||||
use FOS\UserBundle\Model\UserManagerInterface;
|
||||
use HWI\Bundle\OAuthBundle\OAuth\ResourceOwnerInterface;
|
||||
|
|
@ -28,7 +28,7 @@ class UserProviderSpec extends ObjectBehavior
|
|||
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Bundle\CoreBundle\OAuth\UserProvider');
|
||||
$this->shouldHaveType('Sylius\Bundle\UserBundle\OAuth\UserProvider');
|
||||
}
|
||||
|
||||
function it_implements_Hwi_oauth_aware_user_provider_interface()
|
||||
|
|
@ -34,7 +34,7 @@ class OrderController extends FOSRestController
|
|||
public function indexAction()
|
||||
{
|
||||
$orders = $this->getOrderRepository()->findBy(array('user' => $this->getUser()), array('updatedAt' => 'desc'));
|
||||
|
||||
|
||||
$view = $this
|
||||
->view()
|
||||
->setTemplate('SyliusWebBundle:Frontend/Account:Order/index.html.twig')
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ use Doctrine\Common\Collections\Collection;
|
|||
use Sylius\Component\Cart\Model\Cart;
|
||||
use Sylius\Component\Channel\Model\ChannelInterface as BaseChannelInterface;
|
||||
use Sylius\Component\Order\Model\OrderInterface;
|
||||
use Sylius\Component\User\Model\UserInterface as UserComponentInterface;
|
||||
use Sylius\Component\User\Model\UserInterface as BaseUserInterface;
|
||||
use Sylius\Component\Payment\Model\PaymentInterface as BasePaymentInterface;
|
||||
use Sylius\Component\Promotion\Model\CouponInterface as BaseCouponInterface;
|
||||
use Sylius\Component\Promotion\Model\PromotionInterface as BasePromotionInterface;
|
||||
|
|
@ -32,7 +32,7 @@ class Order extends Cart implements OrderInterface
|
|||
/**
|
||||
* User.
|
||||
*
|
||||
* @var UserComponentInterface
|
||||
* @var BaseUserInterface
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ class Order extends Cart implements OrderInterface
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUser(UserComponentInterface $user = null)
|
||||
public function setUser(BaseUserInterface $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@ namespace Sylius\Component\Core\Model;
|
|||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Sylius\Component\Rbac\Model\RoleInterface;
|
||||
use Sylius\Component\User\Model\User as UserComponent;
|
||||
use Sylius\Component\User\Model\User as BaseUser;
|
||||
|
||||
/**
|
||||
* User model.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
*/
|
||||
class User extends UserComponent implements UserInterface
|
||||
class User extends BaseUser implements UserInterface
|
||||
{
|
||||
protected $currency;
|
||||
protected $orders;
|
||||
|
|
|
|||
|
|
@ -14,14 +14,14 @@ namespace Sylius\Component\Core\Model;
|
|||
use Doctrine\Common\Collections\Collection;
|
||||
use Sylius\Component\Rbac\Model\IdentityInterface;
|
||||
use Sylius\Component\Resource\Model\TimestampableInterface;
|
||||
use Sylius\Component\User\Model\UserInterface as UserComponentInterface;
|
||||
use Sylius\Component\User\Model\UserInterface as BaseUserInterface;
|
||||
|
||||
/**
|
||||
* User interface.
|
||||
*
|
||||
* @author Paweł Jędrzejewski <pawel@sylius.org>
|
||||
*/
|
||||
interface UserInterface extends UserComponentInterface, IdentityInterface, TimestampableInterface
|
||||
interface UserInterface extends BaseUserInterface, IdentityInterface, TimestampableInterface
|
||||
{
|
||||
/**
|
||||
* Get currency.
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use Sylius\Component\Pricing\Calculator\CalculatorInterface;
|
|||
class GroupBasedCalculator extends AbstractCalculator implements CalculatorInterface
|
||||
{
|
||||
protected $parameterName = 'groups';
|
||||
protected $className = 'Sylius\Component\Core\Model\GroupInterface';
|
||||
protected $className = 'Sylius\Component\User\Model\GroupInterface';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
namespace Sylius\Component\Core\Promotion\Checker;
|
||||
|
||||
use Sylius\Component\Core\Model\CouponInterface;
|
||||
use Sylius\Component\Core\Model\UserAwareInterface;
|
||||
use Sylius\Component\User\Model\UserAwareInterface;
|
||||
use Sylius\Component\Core\Model\UserInterface;
|
||||
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
|
||||
use Sylius\Component\Promotion\Checker\PromotionEligibilityChecker as BasePromotionEligibilityChecker;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class UserSpec extends ObjectBehavior
|
|||
|
||||
function it_implements_user_component_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Component\User\Model\UserInterface');
|
||||
$this->shouldImplement('Sylius\Component\Core\Model\UserInterface');
|
||||
}
|
||||
|
||||
function it_has_no_shipping_address_by_default()
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
namespace spec\Sylius\Component\Core\Pricing;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
use Sylius\Component\Core\Model\GroupInterface;
|
||||
use Sylius\Component\User\Model\GroupInterface;
|
||||
use Sylius\Component\Pricing\Model\PriceableInterface;
|
||||
|
||||
;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CHANGELOG
|
||||
=========
|
||||
|
||||
### v0.11.0
|
||||
### v0.13.0
|
||||
|
||||
* Initial dev release.
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Component\Core\Model;
|
||||
namespace Sylius\Component\User\Model;
|
||||
|
||||
use FOS\UserBundle\Model\Group as BaseGroup;
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Sylius\Component\Core\Model;
|
||||
namespace Sylius\Component\User\Model;
|
||||
|
||||
use FOS\UserBundle\Model\GroupInterface as BaseGroupInterface;
|
||||
|
||||
|
|
@ -30,10 +30,10 @@ class User extends BaseUser implements UserInterface
|
|||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->createdAt = new \DateTime();
|
||||
$this->oauthAccounts = new ArrayCollection();
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getFullName()
|
||||
|
|
@ -193,4 +193,12 @@ class User extends BaseUser implements UserInterface
|
|||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isDeleted()
|
||||
{
|
||||
return ((null !== $this->deletedAt) && (new \DateTime() >= $this->deletedAt));
|
||||
}
|
||||
}
|
||||
|
|
@ -74,4 +74,11 @@ interface UserInterface extends BaseUserInterface, TimestampableInterface
|
|||
* @return self
|
||||
*/
|
||||
public function addOAuthAccount(UserOAuthInterface $oauth);
|
||||
|
||||
/**
|
||||
* Check whether user is deleted.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDeleted();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
User Component [](http://travis-ci.org/Sylius/Locale)
|
||||
User Component [](http://travis-ci.org/Sylius/User)
|
||||
================
|
||||
|
||||
Managing users in PHP applications.
|
||||
|
|
@ -38,10 +38,10 @@ If you find a bug, please refer to the [Reporting a Bug](http://docs.sylius.org/
|
|||
MIT License
|
||||
-----------
|
||||
|
||||
License can be found [here](https://github.com/Sylius/Locale/blob/master/LICENSE).
|
||||
License can be found [here](https://github.com/Sylius/User/blob/master/LICENSE).
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
The component was originally created by [Paweł Jędrzejewski](http://pjedrzejewski.com).
|
||||
See the list of [contributors](https://github.com/Sylius/Locale/contributors).
|
||||
See the list of [contributors](https://github.com/Sylius/User/contributors).
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"name": "sylius/user",
|
||||
"type": "library",
|
||||
"description": "Locale handling for PHP applications.",
|
||||
"keywords": ["language", "localization", "locale", "i18n", "internationalization"],
|
||||
"description": "User handling for PHP applications.",
|
||||
"keywords": ["user", "registration", "login", "groups"],
|
||||
"homepage": "http://sylius.org",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace spec\Sylius\Component\Core\Model;
|
||||
namespace spec\Sylius\Component\User\Model;
|
||||
|
||||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
|
|
@ -20,12 +20,12 @@ class GroupSpec extends ObjectBehavior
|
|||
{
|
||||
function it_is_initializable()
|
||||
{
|
||||
$this->shouldHaveType('Sylius\Component\Core\Model\Group');
|
||||
$this->shouldHaveType('Sylius\Component\User\Model\Group');
|
||||
}
|
||||
|
||||
function it_implements_Sylius_group_interface()
|
||||
{
|
||||
$this->shouldImplement('Sylius\Component\Core\Model\GroupInterface');
|
||||
$this->shouldImplement('Sylius\Component\User\Model\GroupInterface');
|
||||
}
|
||||
|
||||
function it_extends_FOS_group_model()
|
||||
|
|
@ -14,8 +14,9 @@ namespace spec\Sylius\Component\User\Model;
|
|||
use PhpSpec\ObjectBehavior;
|
||||
|
||||
/**
|
||||
|
||||
*
|
||||
* @author Alexandre Bacco <alexandre.bacco@gmail.com>
|
||||
* @author Bartosz Siejka <bartosz.siejka@lakion.com>
|
||||
*/
|
||||
class UserSpec extends ObjectBehavior
|
||||
{
|
||||
|
|
@ -28,4 +29,47 @@ class UserSpec extends ObjectBehavior
|
|||
{
|
||||
$this->shouldImplement('FOS\UserBundle\Model\UserInterface');
|
||||
}
|
||||
|
||||
function it_sets_user_first_name()
|
||||
{
|
||||
$this->setFirstName('Edward');
|
||||
|
||||
$this->getFirstName()->shouldReturn('Edward');
|
||||
}
|
||||
|
||||
function it_sets_user_last_name()
|
||||
{
|
||||
$this->setLastName('Thatch');
|
||||
|
||||
$this->getLastName()->shouldReturn('Thatch');
|
||||
}
|
||||
|
||||
function it_can_get_full_name()
|
||||
{
|
||||
$this->setFirstName('Edward');
|
||||
$this->setLastName('Kenway');
|
||||
|
||||
$this->getFullName()->shouldReturn('Edward Kenway');
|
||||
}
|
||||
|
||||
function it_should_return_true_if_user_is_deleted()
|
||||
{
|
||||
$deletedAt = new \DateTime('yesterday');
|
||||
$this->setDeletedAt($deletedAt);
|
||||
|
||||
$this->shouldBeDeleted();
|
||||
}
|
||||
|
||||
function it_should_return_false_if_user_is_not_deleted()
|
||||
{
|
||||
$this->shouldNotBeDeleted();
|
||||
}
|
||||
|
||||
function it_should_return_false_if_user_deleted_time_is_future_date()
|
||||
{
|
||||
$deletedAt = new \DateTime('tomorrow');
|
||||
$this->setDeletedAt($deletedAt);
|
||||
|
||||
$this->shouldNotBeDeleted();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue