/** * 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->aActor) { $this->aActor->removeActivity($this); } if (null !== $this->aObject) { $this->aObject->removeActivityRelatedByObjectId($this); } if (null !== $this->aTarget) { $this->aTarget->removeActivityRelatedByTargetId($this); } $this->id = null; $this->actor_id = null; $this->verb = null; $this->object_id = null; $this->target_id = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Interal mechanism to remove Activities from User * * @param User $model * @param mixed $data */ protected function doRemoveActivities(User $model, $data) { $errors = []; foreach ($data as $entry) { if (!isset($entry['id'])) { $errors[] = 'Missing id for Activity'; } else { $related = ActivityQuery::create()->findOneById($entry['id']); $model->removeActivity($related); } } if (count($errors) > 0) { return new ErrorsException($errors); } }