Skip to content

Instantly share code, notes, and snippets.

@ovcharenkovv
Created March 6, 2013 10:36
Show Gist options
  • Save ovcharenkovv/5098428 to your computer and use it in GitHub Desktop.
Save ovcharenkovv/5098428 to your computer and use it in GitHub Desktop.
<?php
namespace Moc\UserBundle\DataFixtures\MongoDB;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Moc\UserBundle\Document\User;
class LoadUserData implements FixtureInterface, ContainerAwareInterface
{
/**
* @var ContainerInterface
*/
private $container;
/**
* {@inheritDoc}
*/
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$athlete = $this->container->get('gscore.gscore.repository.athlete')->findOneByUsagNum(492537);
$admin = new User() ;
$admin->setEmail("[email protected]") ;
$admin->setUsername("admin") ;
$admin->setPlainPassword("admin") ;
$admin->setEnabled(true) ;
$admin->setSuperAdmin(true) ;
$admin->addDeviceToken('test1asd8asd79a8sd7ads9');
if ($athlete) $admin->addFollowedAthlete($athlete);
$manager->persist($admin);
$user = new User() ;
$user->setEmail("[email protected]") ;
$user->setUsername("user") ;
$user->setPlainPassword("user") ;
$user->setEnabled(true) ;
$user->setRoles( array(User::ROLE_DEFAULT) ) ;
$user->addDeviceToken('test2asd8asd79a8sd7ads9');
$user->addDeviceToken('test3asd8asd79a8sd7ads9');
if ($athlete) $user->addFollowedAthlete($athlete);
$manager->persist($user);
$manager->flush();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment