ArticleTopic::buildSubtopicsArray PHP Method

buildSubtopicsArray() private static method

Retrieves the subtopics of the given parent.
private static buildSubtopicsArray ( $p_parentIds ) : array
return array
    private static function buildSubtopicsArray($p_parentIds = 0)
    {
        $p_parentIds = is_array($p_parentIds) ? $p_parentIds : array($p_parentIds);
        $em = \Zend_Registry::get('container')->getService('em');
        $childrenIds = array();
        foreach ($p_parentIds as $p_parentId) {
            $topic = $em->getReference('Newscoop\\NewscoopBundle\\Entity\\Topic', $p_parentId);
            if ($topic) {
                $children = $em->getRepository('Newscoop\\NewscoopBundle\\Entity\\Topic')->childrenWithTranslations($topic);
                foreach ((array) $children->getArrayResult() as $key => $value) {
                    $childrenIds[] = $value['id'];
                }
            }
        }
        return $childrenIds;
    }