Пример #1
0
 /**
  * Convert an associative array to an object user
  *
  * @param array $data the associative array
  *
  * @return \Entity\User the object user
  */
 protected function convertArrayToObject(array $data)
 {
     $user = new User();
     $user->setId($data['id']);
     $user->setUsername($data['username']);
     $user->setPassword($data['password']);
     return $user;
 }
Пример #2
0
 function create_user($row)
 {
     $user = new User();
     $user->setUsername($row['username']);
     $user->setPassword($row['password']);
     $user->setRole($row['role']);
     return $user;
 }
Пример #3
0
 public function createAdmin($email, $username, $password, $roles, $lastName = '', $firstName = '')
 {
     $user = new User();
     $user->setEmail($email);
     $user->setEnabled(0);
     $user->setUsername($username);
     $user->setSubscribe(new \DateTime('now'));
     $user->setRoles(serialize($roles));
     $user->setLastName($lastName);
     $user->setFirstName($firstName);
     $salt = uniqid(mt_rand(), true);
     $options = ['cost' => 11, 'salt' => $salt];
     $user->setSalt($salt);
     $user->setPassword(password_hash($password, PASSWORD_BCRYPT, $options));
     $this->em->persist($user);
     $this->em->flush();
 }
Пример #4
0
<?php

require_once __DIR__ . '/bootstrap_doctrine.php';
use Entity\User;
use Entity\Article;
$factoryManager = new Fixtures\FactoryManager();
$factoryManager->set('user', function ($provider) {
    $user = new User();
    $user->setUsername($provider->get('username', 'John'));
    return $user;
});
$factoryManager->set('article', function ($provider) {
    $article = new Article();
    $article->setAuthor($provider->getRelation('author', 'user'));
    $article->setTitle($provider->get('title', 'The title'));
    $article->setContent($provider->get('content', 'The content'));
    return $article;
});
$storageManager = new Fixtures\StorageManager();
$storageManager->register(new Fixtures\Storage\Doctrine\ORM($entityManager));
$environment = new Fixtures\Environment($factoryManager, $storageManager);
$environment->reset();
$environment->createCollection(100, 'article', array('author' => $environment->create('user')));
 public function setUsername($username)
 {
     $this->__load();
     return parent::setUsername($username);
 }
 /**
  * {@inheritDoc}
  */
 public function setUsername($username)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUsername', [$username]);
     return parent::setUsername($username);
 }