/** * Checks if given tag or at least one of its children is associated to a workspace. * * @param int $tagId * @param array $tagWorkspaces * @param array $hierarchy * * @return bool */ private function isTagDisplayable(WorkspaceTag $tag, array $tagWorkspaces, array $hierarchy) { $displayable = false; $tagId = $tag->getId(); if (isset($tagWorkspaces[$tagId]) && count($tagWorkspaces[$tagId]) > 0 || !is_null($tag->getWorkspace())) { $displayable = true; } else { if (isset($hierarchy[$tagId]) && count($hierarchy[$tagId]) > 0) { $children = $hierarchy[$tagId]; foreach ($children as $child) { $displayable = $this->isTagDisplayable($child, $tagWorkspaces, $hierarchy); if ($displayable) { break; } } } } return $displayable; }