/** * @return AbstractProtoClass **/ public function skipObjectPrefetching(Identifiable $object) { if ($this->depth) { if (!isset($this->skipList[$this->depth][$object->getId()])) { $this->skipList[$this->depth][$object->getId()] = 1; } else { ++$this->skipList[$this->depth][$object->getId()]; } } return $this; }
public function unite(Identifiable $object, Identifiable $old) { Assert::isNotNull($object->getId()); Assert::isTypelessEqual($object->getId(), $old->getId(), 'cannot merge different objects'); $query = OSQL::update($this->getTable()); foreach ($this->getProtoClass()->getPropertyList() as $property) { $getter = $property->getGetter(); if ($property->getClassName() === null) { $changed = $old->{$getter}() !== $object->{$getter}(); } else { /** * way to skip pointless update and hack for recursive * comparsion. **/ $changed = $old->{$getter}() !== $object->{$getter}() || $old->{$getter}() != $object->{$getter}(); } if ($changed) { $property->fillQuery($query, $object); } } if (!$query->getFieldsCount()) { return $object; } $this->targetizeUpdateQuery($query, $object); return $this->doInject($query, $object); }
public function merge(Identifiable $object, $cacheOnly = true) { Assert::isNotNull($object->getId()); $this->checkObjectType($object); $old = Cache::worker($this)->getCachedById($object->getId()); if (!$old) { // unlikely if ($cacheOnly) { return $this->save($object); } else { $old = Cache::worker($this)->getById($object->getId()); } } if ($object === $old) { return $this->save($object); } return $this->unite($object, $old); }
/** * @return BinaryExpression **/ public static function eqId($field, Identifiable $object) { return self::eq($field, DBValue::create($object->getId())); }
private function addObjectToMap(Identifiable $object) { return $this->identityMap[$object->getId()] = $object; }
public function drop(Identifiable $object) { return $this->dropById($object->getId()); }
/** * @param Identifiable $other * * @return bool */ public function isSameAs(Identifiable $other) : bool { return $this->getId() == $other->getId(); }