public function fetchAllAssociatedEntryCounts($associated_sections = null)
    {
        if (is_null($this->get('section_id'))) {
            return null;
        }

        if (is_null($associated_sections)) {
            $section = SectionManager::fetch($this->get('section_id'));
            $associated_sections = $section->fetchChildAssociations();
        }

        if (!is_array($associated_sections) || empty($associated_sections)) {
            return null;
        }

        $counts = array();

        foreach ($associated_sections as $as) {
            $field = FieldManager::fetch($as['child_section_field_id']);
            $parent_section_field_id = $as['parent_section_field_id'];

            if (!is_null($parent_section_field_id)) {
                $search_value = $field->fetchAssociatedEntrySearchValue(
                    $this->getData($as['parent_section_field_id']),
                    $as['parent_section_field_id'],
                    $this->get('id')
                );
            } else {
                $search_value = $this->get('id');
            }

            $counts[$as['child_section_id']][$as['child_section_field_id']] = $field->fetchAssociatedEntryCount($search_value);
        }

        return $counts;
    }
public function fetchAllAssociatedEntryCounts($associated_sections = null)
    {
        if (is_null($this->get('section_id'))) {
            return null;
        }

        if (is_null($associated_sections)) {
            $section = SectionManager::fetch($this->get('section_id'));
            $associated_sections = $section->fetchChildAssociations();
        }

        if (!is_array($associated_sections) || empty($associated_sections)) {
            return null;
        }

        $counts = array();

        foreach ($associated_sections as $as) {
            $field = FieldManager::fetch($as['child_section_field_id']);
            $parent_section_field_id = $as['parent_section_field_id'];

            if (!is_null($parent_section_field_id)) {
                $search_value = $field->fetchAssociatedEntrySearchValue(
                    $this->getData($as['parent_section_field_id']),
                    $as['parent_section_field_id'],
                    $this->get('id')
                );
            } else {
                $search_value = $this->get('id');
            }

            $counts[$as['child_section_id']][$as['child_section_field_id']] = $field->fetchAssociatedEntryCount($search_value);
        }

        return $counts;
    }
public function fetchAllAssociatedEntryCounts ( $ associated_sections = null ) { if ( is_null ( $ this -> get ( 'section_id' ) ) ) { return null ; } if ( is_null ( $ associated_sections ) ) { $ section = SectionManager :: fetch ( $ this -> get ( 'section_id' ) ) ; $ associated_sections = $ section -> fetchChildAssociations ( ) ; } if ( ! is_array ( $ associated_sections ) || empty ( $ associated_sections ) ) { return null ; } $ counts = array ( ) ; foreach ( $ associated_sections as $ as ) { $ field = FieldManager :: fetch ( $ as [ 'child_section_field_id' ] ) ; $ parent_section_field_id = $ as [ 'parent_section_field_id' ] ; if ( ! is_null ( $ parent_section_field_id ) ) { $ search_value = $ field -> fetchAssociatedEntrySearchValue ( $ this -> getData ( $ as [ 'parent_section_field_id' ] ) , $ as [ 'parent_section_field_id' ] , $ this -> get ( 'id' ) ) ; } else { $ search_value = $ this -> get ( 'id' ) ; } $ counts [ $ as [ 'child_section_id' ] ] [ $ as [ 'child_section_field_id' ] ] = $ field -> fetchAssociatedEntryCount ( $ search_value ) ; } return $ counts ; }
Entries may link to other Entries through fields. This function will return the
number of entries that are associated with the current entry as an associative
array. If there are no associated entries, null will be returned.

@param array $associated_sections
An associative array of sections to return the Entry counts from. Defaults to
null, which will fetch all the associations of this Entry.
@throws Exception
@return array
An associative array with the key being the associated Section's ID and the
value being the number of entries associated with this Entry.
Entries may link to other Entries through fields . This function will return the number of entries that are associated with the current entry as an associative array . If there are no associated entries null will be returned .