Newscoop\NewscoopBundle\Services\TopicService::isAttached PHP Метод

isAttached() публичный Метод

If $attachedCount is set to yes, returns an array with the number of topics attached to articles, else returns boolean. By default set to false.
public isAttached ( string | integer $topicId, boolean $attachedCount = false ) : boolean | array
$topicId string | integer Topic id
$attachedCount boolean Switch to include/exclude number of topics
Результат boolean | array
    public function isAttached($topicId, $attachedCount = false)
    {
        $topic = $this->em->getRepository('Newscoop\\Entity\\ArticleTopic')->getTheOccurrenceOfTheTopic($topicId)->getSingleScalarResult();
        $count = (int) $topic;
        if ($attachedCount) {
            if ($count > 0) {
                return array($count, true);
            }
            return array($count, false);
        }
        if ($count > 0) {
            return true;
        }
        return false;
    }