Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundleDocument;
- use DoctrineBundleMongoDBBundleValidatorConstraintsUnique as MongoDBUnique;
- use DoctrineODMMongoDBMappingAnnotations as MongoDB;
- use SymfonyComponentValidatorConstraints as Assert;
- /**
- * @MongoDBDocument(collection="users")
- * @MongoDBUnique(fields="{id, email}")
- */
- class User
- {
- // ...
- /**
- * @MongoDBField(type="collection")
- */
- protected $loginLast90Days;
- // ...
- /**
- * Set loginLast90Days
- *
- * @param collection $loginLast90Days
- * @return $this
- */
- public function setLoginLast90Days($loginLast90Days)
- {
- $this->loginLast90Days = $loginLast90Days;
- return $this;
- }
- /**
- * Get loginLast90Days
- *
- * @return collection $loginLast90Days
- */
- public function getLoginLast90Days()
- {
- return $this->loginLast90Days;
- }
- public function addLoginLast90Days($login)
- {
- $this->loginLast90Days[] = $login;
- return $this;
- }
- public function removeLoginLast90Days($login)
- {
- $this->loginLast90Days->removeElement($login);
- return $this;
- }
- // ...
- }
- $dm = $this->get('doctrine_mongodb');
- $user = $dm->getRepository('AppBundle:User')->findOneBy(array('gmail' => $email));
- $user->addLoginLast90Days(time());
- $dm = $this->get('doctrine_mongodb')->getManager();
- $dm->persist($user);
- $dm->flush();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement