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

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

Removes topic from all articles it is attached to.
public removeTopicFromAllArticles ( string | integer $topicId ) : boolean
$topicId string | integer Topic id
Результат boolean
    public function removeTopicFromAllArticles($topicId)
    {
        $qb = $this->em->createQueryBuilder();
        $topic = $this->em->getReference('Newscoop\\NewscoopBundle\\Entity\\Topic', $topicId);
        $children = $this->getTopicRepository()->childrenQuery($topic)->getArrayResult();
        $attachedTopics = array();
        foreach ($children as $key => $child) {
            if ($this->isAttached($child['id'])) {
                $attachedTopics[] = $child['id'];
            }
        }
        $attachedTopics[] = $topicId;
        $topicsQuery = $qb->delete('Newscoop\\Entity\\ArticleTopic', 'at')->where('at.topic IN (?1)')->setParameter(1, $attachedTopics)->getQuery();
        $topicsQuery->execute();
        return true;
    }