protected function unlinkItem($item)
{
// Convert instance to entity ID
if ($item instanceof AbstractEntity) {
$item = $item->id;
}
$sourceEntityId = $this->getParentEntity()->id;
if ($this->isNull($sourceEntityId) || $this->isNull($item)) {
return false;
}
$firstClassName = $this->extractClassName($this->getParentEntity());
$secondClassName = $this->extractClassName($this->getEntity());
$query = $this->arr([$firstClassName => $sourceEntityId, $secondClassName => $item])->sortKey()->val();
$res = Entity::getInstance()->getDatabase()->delete($this->intermediateCollection, $query);
return $res->getDeletedCount() == 1;
}