Create missing menus for site

@param Site $site

@return string[][]
Newly created menus
558565
private function ensureSiteMenus(Site $site)
    {
        $ret = [];

        if ($this->treeManager && $this->allowedMenus) {
            $storage = $this->treeManager->getMenuStorage();

            foreach ($this->allowedMenus as $prefix => $title) {

                $name = $prefix.'-'.$site->getId();

                if (!$storage->exists($name)) {
                    $ret[$name] = $storage->create($name, ['title' => $this->t($title), 'site_id' => $site->getId()]);
                }
            }
        }

        return $ret;
    }
110719
public function findItemsToIndex(Site $site, int $limit = 50) : array
    {
        $queryBuilder = $this->getQueryBuilder();
        // determine which items to index with this run
        $indexQueueItemRecords = $queryBuilder
            ->select('*')
            ->from($this->table)
            ->andWhere(
                $queryBuilder->expr()->eq('root', $site->getRootPageId()),
                $queryBuilder->expr()->gt('changed', 'indexed'),
                $queryBuilder->expr()->lte('changed', time()),
                $queryBuilder->expr()->eq('errors', $queryBuilder->createNamedParameter(''))
            )
            ->orderBy('indexing_priority', 'DESC')
            ->addOrderBy('changed', 'DESC')
            ->addOrderBy('uid', 'DESC')
            ->setMaxResults($limit)
            ->execute()->fetchAll();

        return $this->getIndexQueueItemObjectsFromRecords($indexQueueItemRecords);
    }
878451
public function environments($site)
    {
        $variables = array('site' => $site);
        $request = $this->get(array('{+base_path}/sites/{site}/envs.json', $variables));
        return new Response\Environments($request);
    }
870454
public function getMenuEntries($location = null)
    {
        $runtimeManager = $this->framework->getRuntimeManager();

        // Give the modules the opportunity to add additional menu entries
        $runtimeManager->executeEvent('\\Zepi\\Web\\General\\Event\\MenuManager\\RegisterAdditionalMenuEntries');
        
        if ($location === null) {
            return $this->menuEntries;
        }
        
        // If this location does not exists, return an empty array
        if (!isset($this->menuEntries[$location])) {
            return array();
        }
        
        // Execute the event
        $menuEntries = $runtimeManager->executeFilter('\\Zepi\\Web\\General\\Filter\\MenuManager\\FilterMenuEntries', $this->menuEntries[$location]);
        
        return $menuEntries;
    }
843143
public function getConnectionsBySite(Site $site)
    {
        $connections = [];

        $solrServers = $this->getConfigurationsBySite($site);
        foreach ($solrServers as $solrServer) {
            $connections[] = $this->getConnectionFromConfiguration($solrServer);
        }

        return $connections;
    }
155039
private function SiteHostCondition(Site $site)
    {
        $siteUrl = $site->GetUrl();
        $host = parse_url($siteUrl, PHP_URL_HOST);
        return new RewriteCondition(new Variable(ServerVariable::HttpHost()), $host);
    }
128795
public function andSiteIs(Site $site)
    {
        $suffix = $this->getSuffix();

        return $this->andWhere($this->getSectionAlias().'._site = :site'.$suffix)
                        ->setParameter('site'.$suffix, $site);
    }
432035
protected function getPageResources(Page $page, Site $site)
    {
        $primaryDomainName = $site->getDomain()->getDomainName();
        $siteId = $site->getSiteId();
        $pageName = $page->getName();
        $pageType = $page->getPageType();

        $pagesResourceId = $this->resourceName->get(self::RESOURCE_SITES, $siteId, self::RESOURCE_PAGES);
        $pageResourceId = $this->resourceName->get(
            self::RESOURCE_SITES,
            $siteId,
            self::RESOURCE_PAGES,
            $pageType,
            $pageName
        );

        $return[$pageResourceId] = [
            'resourceId' => $pageResourceId,
            'parentResourceId' => $pagesResourceId,
            'name' => $primaryDomainName . ' - pages - ' . $pageName,
            'description' => "Resource for page '{$pageName}'" . " of type '{$pageType}' on site '{$primaryDomainName}'"
        ];

        $return[$pageResourceId] = array_merge(
            $this->resources[self::RESOURCE_PAGES],
            $return[$pageResourceId]
        );

        return $return;
    }
303002
private function _getSiteIds( $sitelevel )
	{
		$locale = $this->_context->getLocale();
		$siteIds = array( $locale->getSiteId() );

		if( $sitelevel & MShop_Locale_Manager_Abstract::SITE_PATH ) {
			$siteIds = array_merge( $siteIds, $locale->getSitePath() );
		}

		if( $sitelevel & MShop_Locale_Manager_Abstract::SITE_SUBTREE ) {
			$siteIds = array_merge( $siteIds, $locale->getSiteSubTree() );
		}

		$siteIds = array_unique( $siteIds );

		return $siteIds;
	}
640379
public function getCloningMapping(Site $site)
    {
        if (isset($this->cloningMapping[$site->getId()])) {
            return $this->cloningMapping[$site->getId()];
        }

        $q = $this->db
            ->select('node', 'n')
            ->fields('n', ['parent_nid', 'nid'])
            ->isNotNull('parent_nid')
            ->condition('site_id', $site->id)
            ->condition('status', NODE_PUBLISHED)
            ->orderBy('created', 'ASC')
        ;

        $mapping = [];

        foreach ($q->execute()->fetchAll() as $row) {
            if (isset($mapping[(int) $row->parent_nid])) {
                continue;
            }
            $mapping[(int) $row->parent_nid] = (int) $row->nid;
        }

        $this->cloningMapping[$site->getId()] = $mapping;

        return $mapping;
    }
28859
protected function getSitemapNodesFromSite(ReadSiteInterface $site)
    {
        $nodes = array();
        $nodesCollection = $this->nodeRepository->findPublishedByLanguageAndSiteId($site->getMainAlias()->getLanguage(), $site->getSiteId());

        if ($nodesCollection) {
            /** @var ReadNodeInterface $node */
            foreach ($nodesCollection as $node) {
                $nodes[] = $this->generateNodeInfos($node, $site);
            }
        }

        return $nodes;
    }
842335
static function LoadInstalledToFrontend(Site $site)
    {
        $bundles = InstalledBundle::Schema()->Fetch();
        foreach ($bundles as $bundle)
        {
            $manifest = ClassFinder::Manifest($bundle->GetBundle());
            $manifest->LoadToFrontend($site);
        }
    }
308412
private function findAllMenuWithRole(Site $site, $role)
    {
        return $this->treeManager->getMenuStorage()->loadWithConditions([
            'site_id' => $site->getId(),
            'role'    => $role,
        ]);
    }
278988
public function collectRelativeRoles(Site $context = null)
    {
        $event = new RolesCollectionEvent($this->getDefaultRelativeRoles(), $context);
        $this->dispatcher->dispatch(RolesCollectionEvent::EVENT_NAME, $event);
        return $event->getRoles();
    }
334647
protected function PageTreeUrl(Site $site)
    {
        $args = array('site' => $site->GetID());
        return BackendRouter::ModuleUrl(new PageTree(), $args);
    }
652749
public function setSite(\BackBee\Site\Site $site = null)
    {
        $this->_site = $site;

        return $this;
    }
431970
protected function getRolesFromSite($site)
	{
		$newDataSet = new AnyDataset();
		$it = $this->user->getRolesIterator($site);
		while ($it->hasNext()) {
			$sr = $it->moveNext();
			$dataArray = $sr->getFieldArray($this->user->getRolesTable()->Role);
			if (sizeof($dataArray) > 0) {
				foreach ($dataArray as $roles) {
					$siteName = $sr->getField($this->user->getRolesTable()->Site);
					if ($siteName == "_all") {
						$siteName = $this->myWords->Value("TEXT_ALLSITES");
					}
					$newDataSet->appendRow();
					$newDataSet->addField($this->user->getRolesTable()->Site, $siteName);
					$newDataSet->addField($this->user->getRolesTable()->Role, $roles);
				}	
			}
		}
		return $newDataSet;
	}