Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Initial FOSUserBundle integration #5

Merged
merged 1 commit into from
Feb 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>