/** * @param ContentInterface $about * @param PosterInterface $viewer * * @return string */ public function getPrivacyLabel(ContentInterface $about, PosterInterface $viewer = null) { $isOwner = false; /** * Is poster of content */ if ($about->viewerIsParent()) { $isOwner = true; } $relationType = $about->getPrivacyType(); $parentType = $about->getParentType(); if ($relationType < RELATION_TYPE_CUSTOM) { switch ($relationType) { case RELATION_TYPE_ANYONE: $msgId = 'relation.privacy_label_public'; break; case RELATION_TYPE_OWNER: $msgId = 'relation.' . $parentType . '_privacy_label_owner'; break; case RELATION_TYPE_MEMBER_OF_MEMBER: $msgId = 'relation.' . $parentType . '_privacy_label_member_of_members'; break; case RELATION_TYPE_ADMIN: $msgId = 'relation.' . $parentType . '_privacy_label_admin'; break; case RELATION_TYPE_EDITOR: $msgId = 'relation.' . $parentType . '_privacy_label_editor'; break; case RELATION_TYPE_MEMBER: $msgId = 'relation.' . $parentType . '_privacy_label_member'; break; case RELATION_TYPE_REGISTERED: $msgId = 'relation.' . $parentType . '_privacy_label_registered'; break; default: $msgId = 'relation.' . $parentType . '_privacy_label_custom'; } } if (empty($msgId)) { $relationId = $about->getPrivacyValue(); $item = $this->findById($relationId); if ($item) { $msgId = $item->getRelationTitle(); } } if (empty($msgId)) { $msgId = 'relation.' . $about->getParentType() . '_privacy_label_custom'; } /** * */ $parent = $about->getParent(); if ($isOwner) { return app()->text($msgId, ['$parent\'s' => 'Your', '$parent' => 'You']); } $label = $parent->getTitle(); return app()->text($msgId, ['$parent' => $label]); }