Skip to content

Commit

Permalink
Merge pull request #5 from umpirsky/feature/fos-user
Browse files Browse the repository at this point in the history
Initial FOSUserBundle integration
  • Loading branch information
Paweł Jędrzejewski committed Feb 4, 2013
2 parents 6986a52 + fc08237 commit 12039d1
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
68 changes: 68 additions & 0 deletions DataFixtures/ORM/LoadUsersData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?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\CoreBundle\DataFixtures\ORM;

use Doctrine\Common\Persistence\ObjectManager;
use Sylius\Bundle\CoreBundle\Entity\User;

/**
* User fixtures.
*
* @author Paweł Jędrzejewski <[email protected]>
*/
class LoadUsersData extends DataFixture
{
/**
* {@inheritdoc}
*/
public function load(ObjectManager $manager)
{
$user = new User();

$user->setUsername('administrator');
$user->setEmail('[email protected]');
$user->setPlainPassword('abrakadabra');
$user->setEnabled(true);
$user->setRoles(array('ROLE_SYLIUS_ADMIN'));

$manager->persist($user);
$manager->flush();

$this->setReference('User-Administrator', $user);

for ($i = 1; $i <= 15; $i++) {
$user = new User();

$username = $this->faker->username;

$user->setUsername($username);
$user->setEmail($username.'@example.com');
$user->setPlainPassword($username);
$user->setEnabled($this->faker->boolean());

$manager->persist($user);

$this->setReference('User-'.$i, $user);
}

$manager->flush();

}

/**
* {@inheritdoc}
*/
public function getOrder()
{
return 1;
}
}
23 changes: 23 additions & 0 deletions Entity/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?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\CoreBundle\Entity;

use FOS\UserBundle\Entity\User as BaseUser;

/**
* User entity.
*
* @author Paweł Jędrzjewski <[email protected]>
*/
class User extends BaseUser
{
}
14 changes: 14 additions & 0 deletions Resources/config/doctrine/User.orm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-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">

<entity name="Sylius\Bundle\CoreBundle\Entity\User" table="sylius_user">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
</entity>

</doctrine-mapping>

0 comments on commit 12039d1

Please sign in to comment.