src/Field.php
private function _getSectionSources(Element $element = null): array
    {
        $sources = [];
        $sections = Craft::$app->getSections()->getAllSections();
        $showSingles = false;

        foreach ($sections as $section) {
            if ($section->type === Section::TYPE_SINGLE) {
                $showSingles = true;
            } else if ($element) {
                // Does the section have URLs in the same site as the element we're editing?
                $sectionSiteSettings = $section->getSiteSettings();
                if (isset($sectionSiteSettings[$element->siteId]) && $sectionSiteSettings[$element->siteId]->hasUrls) {
                    $sources[] = 'section:'.$section->uid;
                }
            }
        }

        if ($showSingles) {
            array_unshift($sources, 'singles');
        }

        return $sources;
    }
private function _getSectionSources(Element $element = null): array
    {
        $sources = [];
        $sections = Craft::$app->getSections()->getAllSections();
        $showSingles = false;

        foreach ($sections as $section) {
            if ($section->type === Section::TYPE_SINGLE) {
                $showSingles = true;
            } else if ($element) {
                // Does the section have URLs in the same site as the element we're editing?
                $sectionSiteSettings = $section->getSiteSettings();
                if (isset($sectionSiteSettings[$element->siteId]) && $sectionSiteSettings[$element->siteId]->hasUrls) {
                    $sources[] = 'section:'.$section->uid;
                }
            }
        }

        if ($showSingles) {
            array_unshift($sources, 'singles');
        }

        return $sources;
    }
private function _getSectionSources ( Element $ element = null ) : array { $ sources = [ ] ; $ sections = Craft :: $ app -> getSections ( ) -> getAllSections ( ) ; $ showSingles = false ; foreach ( $ sections as $ section ) { if ( $ section -> type === Section :: TYPE_SINGLE ) { $ showSingles = true ; } else if ( $ element ) { // Does the section have URLs in the same site as the element we're editing? $ sectionSiteSettings = $ section -> getSiteSettings ( ) ; if ( isset ( $ sectionSiteSettings [ $ element -> siteId ] ) && $ sectionSiteSettings [ $ element -> siteId ] -> hasUrls ) { $ sources [ ] = 'section:' . $ section -> uid ; } } } if ( $ showSingles ) { array_unshift ( $ sources , 'singles' ) ; } return $ sources ; }
Returns the available section sources.

@param Element|null $element The element the field is associated with, if there is one
@return array
Returns the available section sources .