Check to see if a layout is valid and available for a theme

@param Site $site Site to lookup
@param string $layoutKey Layout name to search

@return boolean
@throws InvalidArgumentException
494209
public function isLayoutValid(Site $site, $layoutKey)
    {
        $themesConfig = $this->getSiteThemeLayoutsConfig($site->getTheme());

        if (!empty($themesConfig[$layoutKey])) {
            return true;
        }

        return false;
    }
1192924
private function getQuery($siteId, $url = null)
    {
        if (empty($siteId) || !is_numeric($siteId)) {
            throw new InvalidArgumentException('Invalid Site Id To Search By');
        }

        /** @var \Doctrine\ORM\QueryBuilder $queryBuilder */
        $queryBuilder = $this->_em->createQueryBuilder();

        $queryBuilder
            ->select('r')
            ->from(\Rcm\Entity\Redirect::class, 'r', 'r.requestUrl')
            ->leftJoin('r.site', 'site')
            ->where('r.site = :siteId')
            ->orWhere('r.site is null')
            ->orderBy('site.siteId', 'DESC')//Makes site-specific rules take priority
            ->setMaxResults(1)//Improves speed when no match found
            ->setParameter('siteId', $siteId);

        if (!empty($url)) {
            $queryBuilder->andWhere('r.requestUrl = :requestUrl');
            $queryBuilder->setParameter('requestUrl', $url);
        }

        return $queryBuilder->getQuery();
    }
282659
public void addSite(String site) {
		if (siteModel.getIndexOf(site) < 0) {
			siteModel.addElement(site);
			if (currentSite == null) {
				// First site added, automatically select it
				siteModel.setSelectedItem(site);
			}
		}
	}
535829
public function setSite($site)
  {
    if ($site === '?' || $site === '') {
      $this->site = null;
    } elseif (strlen(preg_replace('/[^a-zA-Z]/', '', $site) < 2)) {
      // Some sites have been non-letter gibberish.
      $this->site = null;
    } else {
      $site = Util::foreignLettersToEnglishLetters($site);
      $site = Util::titleCaseIfCurrentlyAllCaps($site);
      $this->site = $site;
    }
  }
663785
public function isValid($siteId, $pageName, $pageType = PageTypes::NORMAL)
    {
        $isValidQueryBuilder = $this->_em->createQueryBuilder();
        $isValidQueryBuilder->select('page.pageId')
            ->from(\Rcm\Entity\Page::class, 'page')
            ->where('page.name = :pageName')
            ->andWhere('page.pageType = :pageType')
            ->andWhere('page.site = :siteId')
            ->setParameter('pageName', $pageName)
            ->setParameter('pageType', $pageType)
            ->setParameter('siteId', $siteId);

        $result = $isValidQueryBuilder->getQuery()->getScalarResult();

        if (!empty($result)) {
            return true;
        }

        return false;
    }
614766
def is_valid_sites(self):
        
        if 'site_model' in self.inputs and 'sites' in self.inputs:
            return False
        elif 'site_model' in self.inputs and self.sites:
            return False
        elif 'sites' in self.inputs and self.sites:
            return False
        elif self.sites and self.region and self.region_grid_spacing:
            return False
        else:
            return True
266780
private ComboBox createSiteSelect(CmsObject cms) {

        final IndexedContainer availableSites = CmsVaadinUtils.getAvailableSitesContainer(cms, SITE_CAPTION);
        ComboBox combo = new ComboBox(null, availableSites);
        combo.setTextInputAllowed(true);
        combo.setNullSelectionAllowed(false);
        combo.setWidth("200px");
        combo.setInputPrompt(
            Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0));
        combo.setItemCaptionPropertyId(SITE_CAPTION);
        combo.select(cms.getRequestContext().getSiteRoot());
        combo.setFilteringMode(FilteringMode.CONTAINS);
        combo.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {

                String value = (String)event.getProperty().getValue();
                if (availableSites.containsId(value)) {
                    changeSite(value, null);
                    m_appContext.updateOnChange();
                    availableSites.removeAllContainerFilters();
                }
            }
        });
        if (Page.getCurrent().getBrowserWindowHeight() > 650) {
            combo.setPageLength(20);
        }
        return combo;
    }
967996
public function generateSitePackage($packageKey, $siteName)
    {
        $this->packageManager->createPackage($packageKey, [
            'type' => 'neos-site',
            "require" => [
                "neos/neos" => "*",
                "neos/nodetypes" => "*"
            ],
            "suggest" => [
                "neos/seo" => "*"
            ]
        ]);

        $this->generateSitesXml($packageKey, $siteName);
        $this->generateSitesRootFusion($packageKey, $siteName);
        $this->generateSitesPageFusion($packageKey, $siteName);
        $this->generateDefaultTemplate($packageKey, $siteName);
        $this->generateNodeTypesConfiguration($packageKey);
        $this->generateAdditionalFolders($packageKey);

        return $this->generatedFiles;
    }
1235612
public function isEnabledForWebsite($key, $websiteId = null)
    {
        return $this->getConfigValue($key, $websiteId) === self::CONFIG_ENABLED;
    }
444167
public boolean isSiteUnderSite(String siteRootPath) {

        for (String siteRoot : getSiteRoots()) {
            if ((siteRootPath.length() > siteRoot.length())
                & siteRootPath.startsWith(CmsFileUtil.addTrailingSeparator(siteRoot))) {
                return true;
            }
        }
        return false;
    }
75518
public function save(Site $site)
    {
        $id = $site->getId();
        if ($id == 0) {
            return $this->getTableGateway()->insert($site->toArray());
        } elseif ($this->findById($id)) {
            return $this->getTableGateway()->update($site->toArray(), array("id" => $id));
        } else {
            return NULL;
        }
    }
1147573
public function checkValidPagesRecursive($siteMenu = array())
    {
        $checkedSiteMenu = array();
        
        foreach($siteMenu as $key => $val){
            
            if($val['menu'] != 'NONE'){
                
                if($val['menu'] == 'NOLINK'){
                    $val['uri'] = '#';
                }
                
                if(!empty($val['pages'])){
                    
                   $pages  = $this->checkValidPagesRecursive($val['pages']);
                   
                   if(!empty($pages)){
                       $val['pages'] = $pages;
                   }
                }
                
                $checkedSiteMenu[] = $val;
            }
            
        }
        
        return $checkedSiteMenu;
    }
1132823
public function editAction(Site $site)
    {
        try {
            $sitePackage = $this->packageManager->getPackage($site->getSiteResourcesPackageKey());
        } catch (\Exception $e) {
            $this->addFlashMessage('The site package with key "%s" was not found.', 'Site package not found', Message::SEVERITY_ERROR, [htmlspecialchars($site->getSiteResourcesPackageKey())]);
        }

        $this->view->assignMultiple([
            'site' => $site,
            'sitePackage' => isset($sitePackage) ? $sitePackage : [],
            'domains' => $this->domainRepository->findBySite($site),
            'assetCollections' => $this->assetCollectionRepository->findAll()
        ]);
    }
755555
public function siteCommand($packageKey, $siteName)
    {
        if (!$this->packageManager->isPackageKeyValid($packageKey)) {
            $this->outputLine('Package key "%s" is not valid. Only UpperCamelCase in the format "Vendor.PackageKey", please!', [$packageKey]);
            $this->quit(1);
        }

        if ($this->packageManager->isPackageAvailable($packageKey)) {
            $this->outputLine('Package "%s" already exists.', [$packageKey]);
            $this->quit(1);
        }

        $generatedFiles = $this->generatorService->generateSitePackage($packageKey, $siteName);
        $this->outputLine(implode(PHP_EOL, $generatedFiles));
    }
1338404
private boolean validate(CmsFavoriteEntry entry) {

        try {
            String siteRoot = entry.getSiteRoot();
            if (!m_okSiteRoots.contains(siteRoot)) {
                m_rootCms.readResource(siteRoot);
                m_okSiteRoots.add(siteRoot);
            }
            CmsUUID project = entry.getProjectId();
            if (!m_okProjects.contains(project)) {
                m_cms.readProject(project);
                m_okProjects.add(project);
            }
            for (CmsUUID id : Arrays.asList(entry.getDetailId(), entry.getStructureId())) {
                if ((id != null) && !m_okStructureIds.contains(id)) {
                    m_cms.readResource(id, CmsResourceFilter.IGNORE_EXPIRATION.addRequireVisible());
                    m_okStructureIds.add(id);
                }
            }
            return true;

        } catch (Exception e) {
            LOG.info("Favorite entry validation failed: " + e.getLocalizedMessage(), e);
            return false;
        }

    }
1266058
private function createRootPage($site, $layout)
    {
        $pagebuilder = $this->bbapp->getContainer()->get('pagebuilder');
        $pagebuilder
            ->setUid(md5('root-' . $site->getLabel()))
            ->setTitle('Home')
            ->setLayout($layout)
            ->setSite($site)
            ->setUrl('/')
            ->putOnlineAndHidden()
        ;

        $page = $pagebuilder->getPage();
        $this->entyMgr->persist($page);
        $this->entyMgr->flush($page);

        return $page;
    }
746678
public function tasksEdit($task, $site = null)
    {
        if (!count($task)) {
            throw new \InvalidArgumentException(
                'Parameter `task` must contain a data'
            );
        }

        /* @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            "/tasks/{$task['id']}/edit",
            "POST",
            $this->fillSite(
                $site,
                ['task' => json_encode($task)]
            )
        );
    }