src/Field.php
private function _getCategorySources(Element $element = null): array
    {
        $sources = [];

        if ($element) {
            $categoryGroups = Craft::$app->getCategories()->getAllGroups();

            foreach ($categoryGroups as $categoryGroup) {
                // Does the category group have URLs in the same site as the element we're editing?
                $categoryGroupSiteSettings = $categoryGroup->getSiteSettings();
                if (isset($categoryGroupSiteSettings[$element->siteId]) && $categoryGroupSiteSettings[$element->siteId]->hasUrls) {
                    $sources[] = 'group:'.$categoryGroup->uid;
                }
            }
        }

        return $sources;
    }
private function _getCategorySources(Element $element = null): array
    {
        $sources = [];

        if ($element) {
            $categoryGroups = Craft::$app->getCategories()->getAllGroups();

            foreach ($categoryGroups as $categoryGroup) {
                // Does the category group have URLs in the same site as the element we're editing?
                $categoryGroupSiteSettings = $categoryGroup->getSiteSettings();
                if (isset($categoryGroupSiteSettings[$element->siteId]) && $categoryGroupSiteSettings[$element->siteId]->hasUrls) {
                    $sources[] = 'group:'.$categoryGroup->uid;
                }
            }
        }

        return $sources;
    }
private function _getCategorySources ( Element $ element = null ) : array { $ sources = [ ] ; if ( $ element ) { $ categoryGroups = Craft :: $ app -> getCategories ( ) -> getAllGroups ( ) ; foreach ( $ categoryGroups as $ categoryGroup ) { // Does the category group have URLs in the same site as the element we're editing? $ categoryGroupSiteSettings = $ categoryGroup -> getSiteSettings ( ) ; if ( isset ( $ categoryGroupSiteSettings [ $ element -> siteId ] ) && $ categoryGroupSiteSettings [ $ element -> siteId ] -> hasUrls ) { $ sources [ ] = 'group:' . $ categoryGroup -> uid ; } } } return $ sources ; }
Returns the available category sources.

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