Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "_id" : ObjectId("5995ba75a48bb0217c5fabe7"),
- "type" : "staff",
- "firstname" : "Thomas",
- "lastname" : "Dupont",
- "email" : "test.test@gmail.com",
- "password" : "$P$BtCPQaU7mcOqtT7Bmj4h4YUpcy/ont1",
- "role" : [
- "ADMIN"
- ],
- "apikey" : "4a6615e073f0267f1a6b258ed1750526",
- "job" : "dev",
- "phoneNumber" : "0651193342",
- "connectionFailed" : {
- "number" : 1,
- "time" : 1503411126
- }
- }
- <?php
- // src/AppBundle/Document/User.php
- namespace ApiBundleDocument;
- use DoctrineODMMongoDBMappingAnnotations as MongoDB;
- use ApiBundleDocument{Staff, Customer};
- /**
- * @MongoDBDocument
- * @MongoDBInheritanceType("SINGLE_COLLECTION")
- * @MongoDBDiscriminatorField("type")
- * @MongoDBDiscriminatorMap({"staff"="Staff", "customer"="Customer"})
- */
- class User
- {
- /**
- * @MongoDBId(strategy="auto")
- */
- protected $id;
- /**
- * @MongoDBField(type="string")
- */
- protected $firstname;
- /**
- * @MongoDBField(type="string")
- */
- protected $lastname;
- /**
- * @MongoDBField(type="string")
- */
- protected $email;
- /**
- * @MongoDBField(type="string")
- */
- protected $password;
- /**
- * @MongoDBField(type="collection")
- */
- protected $role = [];
- /**
- * @MongoDBField(type="string")
- */
- protected $apikey;
- /**
- * @MongoDBHash
- */
- protected $connectionFailed;
- /**
- * Set type
- *
- * @param string $type
- * @return $this
- */
- public function setType($type)
- {
- $this->type = $type;
- return $this;
- }
- /**
- * Get type
- *
- * @return string $type
- */
- public function getType()
- {
- return get_called_class();
- }
- /**
- * Get id
- *
- * @return id $id
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set firstname
- *
- * @param string $firstname
- * @return $this
- */
- public function setFirstname($firstname)
- {
- $this->firstname = $firstname;
- return $this;
- }
- /**
- * Get firstname
- *
- * @return string $firstname
- */
- public function getFirstname()
- {
- return $this->firstname;
- }
- /**
- * Set lastname
- *
- * @param string $lastname
- * @return $this
- */
- public function setLastname($lastname)
- {
- $this->lastname = $lastname;
- return $this;
- }
- /**
- * Get lastname
- *
- * @return string $lastname
- */
- public function getLastname()
- {
- return $this->lastname;
- }
- /**
- * Set email
- *
- * @param string $email
- * @return $this
- */
- public function setEmail($email)
- {
- $this->email = $email;
- return $this;
- }
- /**
- * Get email
- *
- * @return string $email
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set password
- *
- * @param string $password
- * @return $this
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $this;
- }
- /**
- * Get password
- *
- * @return string $password
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * Set role
- *
- * @param collection $role
- * @return $this
- */
- public function setRole($role)
- {
- $this->role = $role;
- return $this;
- }
- /**
- * Get role
- *
- * @return collection $role
- */
- public function getRole()
- {
- return $this->role;
- }
- public function toArray() {
- $tmp = [];
- foreach($this as $key => $value) {
- $tmp[$key] = $value;
- }
- return $tmp;
- }
- /**
- * Set apikey
- *
- * @return $this
- */
- public function setApikey()
- {
- $this->apikey = md5(uniqid());
- return $this;
- }
- /**
- * Get apikey
- *
- * @return string $apikey
- */
- public function getApikey()
- {
- return $this->apikey;
- }
- /**
- * Set connectionFailed
- *
- * @param hash $connectionFailed
- * @return $this
- */
- public function setConnectionFailed($connectionFailed)
- {
- $this->connectionFailed = $connectionFailed;
- return $this;
- }
- /**
- * Get connectionFailed
- *
- * @return hash $connectionFailed
- */
- public function getConnectionFailed()
- {
- return $this->connectionFailed;
- }
- }
- $user = $this->dm
- ->getRepository('ApiBundle:User')
- ->findOneBy(['email' => $email]);
- return $user->toArray();
- php bin/console cache:clear
- rm -rf app/cache/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement