Example #1
0
 /**
  * Clears the current object, sets all attributes to their default values and removes
  * outgoing references as well as back-references (from other objects to this one. Results probably in a database
  * change of those foreign objects when you call `save` there).
  */
 public function clear()
 {
     if (null !== $this->aUser) {
         $this->aUser->removeSession($this);
     }
     $this->token = null;
     $this->user_id = null;
     $this->ip = null;
     $this->user_agent = null;
     $this->browser = null;
     $this->device = null;
     $this->os = null;
     $this->location = null;
     $this->created_at = null;
     $this->updated_at = null;
     $this->alreadyInSave = false;
     $this->clearAllReferences();
     $this->resetModified();
     $this->setNew(true);
     $this->setDeleted(false);
 }
Example #2
0
 /**
  * Interal mechanism to remove Sessions from User
  * 
  * @param User $model
  * @param mixed $data
  */
 protected function doRemoveSessions(User $model, $data)
 {
     $errors = [];
     foreach ($data as $entry) {
         if (!isset($entry['id'])) {
             $errors[] = 'Missing id for Session';
         } else {
             $related = SessionQuery::create()->findOneById($entry['id']);
             $model->removeSession($related);
         }
     }
     if (count($errors) > 0) {
         return new ErrorsException($errors);
     }
 }