public function isSharedWith(Bubble $bubble = null, $depth = 0) { if ($depth > 20) { return false; } if (!$bubble) { return true; } if (!$this->getAuthService()->hasIdentity()) { return false; } if (empty($bubble->getShares())) { return false; } foreach ($bubble->getShares() as $share) { /* @var $share \BubblePle\Entity\BubbleShare */ if ($share->getSharedWith() == $this->getAuthService()->getIdentity()) { return true; } } $parents = $bubble->getParents(); foreach ($parents as $parent) { if ($this->isSharedWith($parent->getFrom(), $depth + 1)) { return true; } } return false; }