/** * Additional save functionality (e.g. update search index) * * @param mixed $connection a database connection object * @return QubitInformationObject self-reference */ public function save($connection = null) { // TODO $cleanObject = $this->object->clean; $cleanObjectId = $this->__get('objectId', array('clean' => true)); // TODO $cleanSubject = $this->subject->clean; $cleanSubjectId = $this->__get('subjectId', array('clean' => true)); parent::save($connection); if ($this->indexOnSave()) { if ($this->objectId != $cleanObjectId && null !== QubitInformationObject::getById($cleanObjectId)) { QubitSearch::updateInformationObject(QubitInformationObject::getById($cleanObjectId)); } if ($this->subjectId != $cleanSubjectId && null != QubitInformationObject::getById($cleanSubjectId)) { QubitSearch::updateInformationObject(QubitInformationObject::getById($cleanSubjectId)); } if ($this->object instanceof QubitInformationObject) { QubitSearch::updateInformationObject($this->object); } if ($this->subject instanceof QubitInformationObject) { QubitSearch::updateInformationObject($this->subject); } } return $this; }