Get all roles to be applied to all maps of a Site.
@param mixed $nb_site Site to retrieve Site Map Roles.
@return CNabuSiteMapRoleList Returns a Site Map Role List with roles. If no roles the list is empty.
776631
static public function getMapRolesForSite($nb_site)
    {
        $nb_site_id = nb_getMixedValue($nb_site, NABU_SITE_FIELD_ID);
        if (is_numeric($nb_site_id)) {
            $retval = CNabuEngine::getEngine()
                    ->getMainDB()
                    ->getQueryAsObjectArray(
                        '\nabu\data\site\CNabuSiteMapRole', null,
                        'select smr.* '
                        . 'from nb_site_map sm, nb_site_map_role smr '
                       . 'where sm.nb_site_map_id=smr.nb_site_map_id '
                         . 'and sm.nb_site_id=%site_id$d '
                       . 'order by sm.nb_site_map_order, smr.nb_role_id',
                        array(
                            'site_id' => $nb_site_id
                        ), null, true
                    )
            ;
        } else {
            $retval = null;
        }

        return $retval;
    }
534339
public function setSiteTargetId(int $nb_site_target_id) : CNabuDataObject
    {
        if ($nb_site_target_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_target_id")
            );
        }
        $this->setValue('nb_site_target_id', $nb_site_target_id);
        
        return $this;
    }
308412
private function findAllMenuWithRole(Site $site, $role)
    {
        return $this->treeManager->getMenuStorage()->loadWithConditions([
            'site_id' => $site->getId(),
            'role'    => $role,
        ]);
    }
1172655
public function getWebsiteMapper()
    {
        if (null === $this->websiteMapper) {
            $this->websiteMapper = $this->serviceLocator->get('playgroundcore_website_mapper');
        }

        return $this->websiteMapper;
    }
844889
public static function getSitesForUser($nb_user)
    {
        if (is_numeric ($nb_user_id = nb_getMixedValue($nb_user, NABU_USER_FIELD_ID))) {
            $retval = CNabuSiteUser::buildObjectListFromSQL(
                'nb_site_id',
                'SELECT su.*
                   FROM nb_site_user su, nb_user u, nb_site s
                  WHERE su.nb_user_id=u.nb_user_id
                    AND su.nb_site_id=s.nb_site_id
                    AND su.nb_user_id=%user_id$d',
                array(
                    'user_id' => $nb_user_id
                ),
                ($nb_user instanceof CNabuUser ? $nb_user : null)
            );
        } else {
            $retval = new CNabuSiteUserList();
        }

        return $retval;
    }
199062
protected function getSiteByNodeName($siteNodeName)
    {
        $site = $this->siteRepository->findOneByNodeName($siteNodeName);

        if ($site === null) {
            $site = new Site($siteNodeName);
            $this->siteRepository->add($site);
        } else {
            $this->siteRepository->update($site);
        }

        return $site;
    }
824347
public function getRole($force = false)
     {
         if ($this->nb_role === null || $force) {
             $this->nb_role = null;
             if ($this->isValueNumeric('nb_role_id')) {
                 $nb_role = new CNabuRole($this);
                 if ($nb_role->isFetched()) {
                     $this->nb_role = $nb_role;
                 }
             }
         }

         return $this->nb_role;
     }
1278867
private function createClusteredFile(CNabuSite $nb_site)
    {
        $file = new CApacheClusteredFile($this, $this->nb_server, $nb_site);
        $file->create();
        $path = self::NABU_APACHE_ETC_PATH . DIRECTORY_SEPARATOR . $nb_site->getBasePath();

        if (!is_dir($path)) {
            mkdir($path, 0755, true);
        }
        if (!is_dir($path)) {
            throw new ENabuCoreException(ENabuCoreException::ERROR_FOLDER_NOT_FOUND, array($path));
        }
        $filename = $path . DIRECTORY_SEPARATOR . NABU_VHOST_CONFIG_FILENAME;
        $file->exportToFile($filename);
    }
278988
public function collectRelativeRoles(Site $context = null)
    {
        $event = new RolesCollectionEvent($this->getDefaultRelativeRoles(), $context);
        $this->dispatcher->dispatch(RolesCollectionEvent::EVENT_NAME, $event);
        return $event->getRoles();
    }
304885
public static function getSiteRolesForSite($nb_site) : CNabuSiteRoleList
    {
        if (is_numeric($nb_site_id = nb_getMixedValue($nb_site, NABU_SITE_FIELD_ID))) {
            $retval = CNabuSiteRole::buildObjectListFromSQL(
                'nb_role_id',
                'select * '
                . 'from nb_site_role '
               . 'where nb_site_id=%site_id$d',
                array(
                    'site_id' => $nb_site_id
                )
            );
            if ($nb_site instanceof CNabuSite) {
                $retval->iterate(function($key, CNabuSiteRole $nb_site_role) use ($nb_site) {
                    $nb_site_role->setSite($nb_site);
                    return true;
                });
            }
        } else {
            $retval = new CNabuSiteRoleList();
        }

        return $retval;
    }
10239
public function addRootSiteMapForURL($order, CNabuRole $nb_role = null)
    {
        if ($nb_role === null) {
            $nb_role = $this->nb_engine->getHTTPServer()->getSite()->getDefaultRole();
        }

        $nb_site_map = new CNabuBuiltInSiteMap();
        $nb_site_map->setOrder($order);

        return $this->addRootSiteMap($nb_site_map);
    }
177295
public function setSiteId(int $nb_site_id) : CNabuDataObject
    {
        if ($nb_site_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_id")
            );
        }
        $this->setValue('nb_site_id', $nb_site_id);
        
        return $this;
    }
222652
public function getSiteRoles(bool $force = false) : CNabuSiteRoleList
    {
        if ($this->nb_site_role_list->isEmpty() || $force) {
            $this->nb_site_role_list->clear();
            $this->nb_site_role_list->merge(CNabuSiteRole::getSiteRolesForSite($this));
        }

        return $this->nb_site_role_list;
    }
1055539
public function forRole(string $role_id, bool $no_cache = false): array
    {
        if (($collection = &$this->cacheKey(__FUNCTION__, $role_id)) !== null && !$no_cache) {
            return $collection; // Already cached this.
        }
        $collection = []; // Initialize.

        if ($role_id === 'super_admin') {
            $role_id = 'administrator';

            if ($this->Wp->is_multisite) {
                $collection = array_merge($collection, [
                    'manage_network'         => 'manage_network',
                    'manage_sites'           => 'manage_sites',
                    'manage_network_users'   => 'manage_network_users',
                    'manage_network_plugins' => 'manage_network_plugins',
                    'manage_network_themes'  => 'manage_network_themes',
                    'manage_network_options' => 'manage_network_options',
                ]);
            }
        }
        $role = get_role($role_id); // If role exists.

        foreach (array_keys($role->capabilities ?? []) as $_role_cap) {
            $collection[$_role_cap] = $_role_cap;
        } // unset($_role_cap); // Housekeeping.

        asort($collection, SORT_NATURAL);

        return $collection;
    }
852691
public function getSiteAccesses($mandatorId = null, $siteAccess = null)
    {
        if ($mandatorId) {
            $siteAccesses = $this->getSiteaccessesByMandatorId($mandatorId);
        } elseif ($siteAccess) {
            $siteAccesses = array($siteAccess);
        } else {
            $siteAccesses = array($this->siteAccess->name);
        }

        return $siteAccesses;
    }
1242247
public function setSiteTargetCTAId(int $nb_site_target_cta_id) : CNabuDataObject
    {
        if ($nb_site_target_cta_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_site_target_cta_id")
            );
        }
        $this->setValue('nb_site_target_cta_id', $nb_site_target_cta_id);
        
        return $this;
    }
139323
protected function getCredentialListMappings() {
        if (!$this->_credentialListMappings) {
            $this->_credentialListMappings = new AuthRegistrationsCredentialListMappingList(
                $this->version,
                $this->solution['accountSid'],
                $this->solution['domainSid']
            );
        }

        return $this->_credentialListMappings;
    }