Пример #1
0
 /**
  * @param DataMapper $mapper
  * @param User $user
  * @param string $type
  * @return Token
  */
 public function createToken(DataMapper $mapper, User $user, $type)
 {
     $this->assert($mapper->getEntityClass() == Token::class);
     $code = preg_replace('/[^a-zA-Z0-9\\_\\-]+/', null, Rand::getString(100));
     return $mapper->create(['user' => $user, 'code' => sprintf('%d.%d.%s', $user->getId(), time(), $code), 'type' => $type]);
 }
Пример #2
0
 /**
  * @return int|null
  */
 public function getRecordIdOrNull()
 {
     return $this->existingRecord ? $this->existingRecord->getId() : null;
 }