Ejemplo n.º 1
0
 /**
  * @param \AppBundle\Model\User $user
  * @param $skillId
  * @return mixed
  */
 public function getSkillValues(\AppBundle\Model\User $user, $skillId)
 {
     $sql = sprintf("\n                SELECT\n                  `uhs`.`user_id` AS `userId`,\n                  `uhs`.`value`,\n                  (`uhs`.`user_id` = %d) AS `isAttacker`\n                FROM `combat` AS `c`\n                JOIN `user_has_combat` AS `uhc` ON (`c`.`id` = `uhc`.`combat_id`)\n                JOIN `user_has_skill` AS `uhs` ON (`uhc`.`user_id` = `uhs`.`user_id`)\n                WHERE\n                    `c`.`id` = %d AND\n                    `uhs`.`skill_id` = %d;\n                ", $user->getEntityHint()->getId(), $this->getEntityHint()->getId(), $skillId);
     /** @var Statement $stmt */
     $stmt = $this->getDoctrineManager()->getConnection()->prepare($sql);
     $stmt->execute();
     return $stmt->fetchAll();
 }
Ejemplo n.º 2
0
 public function loadUserByUsername($username)
 {
     $response = $this->client->get(sprintf('/user?access_token=%s', $username));
     $userData = $response->json();
     if (!$userData) {
         throw new \LogicException('Did not managed to get your user info from Github.');
     }
     $user = new User();
     $user->createFrom($userData);
     return $user;
 }
Ejemplo n.º 3
0
 /**
  * @return int
  */
 public function getOwnerId()
 {
     if (!$this->owner) {
         return null;
     }
     return $this->owner->getId();
 }
Ejemplo n.º 4
0
 /**
  * Set email
  *
  * @param string $email
  *
  * @return User
  */
 public function setEmail($email)
 {
     if ($this->email && $this->email != $email) {
         $this->isEmailChanged = true;
     }
     return parent::setEmail($email);
 }
Ejemplo n.º 5
0
 public function testRunningMigrations()
 {
     static::bootKernel();
     // create user table
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email');
         $table->string('password');
         $table->timestamps();
     });
     User::create(['name' => 'John Doe', 'email' => '*****@*****.**', 'password' => 'pa$$word']);
 }
Ejemplo n.º 6
0
 /**
  * @param User $user
  *
  * @return array
  */
 public function normalizeUser(User $user)
 {
     $annotations = [];
     foreach ($user->getAnnotations() as $key => $annotation) {
         $annotations[] = ['key' => $key, 'value' => $annotation];
     }
     return ['reference' => $user->getReference(), 'firstName' => $user->getFirstName(), 'lastName' => $user->getLastName(), 'loginName' => $user->getLoginName(), 'annotations' => $annotations];
 }
Ejemplo n.º 7
0
 /**
  * User constructor.
  */
 public function __construct()
 {
     parent::__construct();
 }
Ejemplo n.º 8
0
 /**
  * @inheritdoc
  *
  * @param User $other
  */
 public function compareTo($other)
 {
     $ref1 = strtoupper($this->getReference());
     $ref2 = strtoupper($other->getReference());
     $c = new \Collator('en');
     return $c->compare($ref1, $ref2);
 }