save a Site
you can pass the Site object or an array with the fields
if you pass an array the keys must be with underscore and not with CamelCase
@param Site|array $site
@return Site
346618
public function save($site)
    {

        if (is_array($site)) {
            $siteData = $site;
            if ($site['id'] > 0) {
                $site = $this->find($site['id']);
            } else {
                $site = new Site();
            }
            $this->assignArrayToObject($site, $siteData);
        } else if (!($site instanceof Site)) {
            $this->addErrorMessage(self::ERROR_WRONG_OBJECT);
        }

        if (!$this->hasError()) {
            $check = $this->siteManager->save($site);
            if ($check) {
                $this->addSuccessMessage(self::SUCCESS_SAVED);
            }
        }

        return $site;
    }
1023639
public function ordersCreate(array $order, $site = null)
    {
        if (!count($order)) {
            throw new \InvalidArgumentException(
                'Parameter `order` must contains a data'
            );
        }

        /* @noinspection PhpUndefinedMethodInspection */
        return $this->client->makeRequest(
            '/orders/create',
            "POST",
            $this->fillSite($site, ['order' => json_encode($order)])
        );
    }
93254
def save_site(self, create=True):
        
        self._load_sites()
        if create:
            self.sites.append(self.site_name)

        task.save_new_site(self.site_name, self.sitedir, self.target, self.port,
            self.address, self.site_url, self.passwords)
1117603
private function createRootPage(SiteInterface $site): PageInterface
    {
        foreach ($this->router->getRouteCollection()->all() as $name => $route) {
            if ('/' === $route->getPath()) {
                $requirements = $route->getRequirements();
                $name = trim($name);

                return $this->pageManager->create([
                    'routeName' => $name,
                    'name' => $name,
                    'url' => $route->getPath(),
                    'site' => $site,
                    'requestMethod' => $requirements['_method'] ?? 'GET|POST|HEAD|DELETE|PUT',
                    'slug' => '/',
                ]);
            }
        }

        return $this->pageManager->create([
            'routeName' => PageInterface::PAGE_ROUTE_CMS_NAME,
            'name' => 'Homepage',
            'url' => '/',
            'site' => $site,
            'requestMethod' => 'GET|POST|HEAD|DELETE|PUT',
            'slug' => '/',
        ]);
    }
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;
	}
47737
protected function getInitializedIndexService(Site $site)
    {
        $indexService = GeneralUtility::makeInstance(IndexService::class, /** @scrutinizer ignore-type */ $site);
        $indexService->setContextTask($this);
        return $indexService;
    }
687102
public static function getSocialProfile($site = 'facebook')
    {
        $config = \Phalcon\DI::getDefault()->getConfig()->social_config->toArray(); //dirname(dirname(dirname(__FILE__ ))) . "/config/social_config.php";
        $hybridauth = new \Hybridauth\Hybridauth($config);

        //$adapter = $hybridauth->authenticate( "Google" );
        $adapter = $hybridauth->authenticate($site);

        // request user profile
        return $adapter->getUserProfile();
    }
50626
protected function prepareDefaultValues(
        Site $site,
        array $defaultSiteSettings,
        string $createdByUserId,
        string $createdReason
    ) {
        $defaults = $this->getDefaultSiteValues(
            $defaultSiteSettings,
            $createdByUserId,
            $createdReason
        );

        foreach ($defaults as $key => $value) {
            $getMethod = 'get' . ucfirst($key);
            $setMethod = 'set' . ucfirst($key);

            $currentValue = $site->$getMethod();

            if (empty($currentValue)) {
                $site->$setMethod($value);
            }
        }

        return $site;
    }
1014058
public function getConfigurationsBySite(Site $site)
    {
        $solrConfigurations = [];

        $allConfigurations = $this->getAllConfigurations();
        foreach ($allConfigurations as $configuration) {
            if ($configuration['rootPageUid'] == $site->getRootPageId()) {
                $solrConfigurations[] = $configuration;
            }
        }

        return $solrConfigurations;
    }
840791
public function transform($site, array $params = array())
    {
        if (!$site instanceof SiteInterface) {
            throw new TransformerParameterTypeException();
        }

        $facade = $this->newFacade();

        $facade->id = $site->getId();
        $facade->siteId = $site->getSiteId();
        $facade->name = $site->getName();

        if ($this->hasGroup(CMSGroupContext::SITE_MAIN_ALIAS)) {
            $facade->mainAlias = $this->getContext()->transform('site_alias', $site->getMainAlias());
        }

        foreach ($site->getLanguages() as $language) {
            $facade->addLanguage($language);
        }

        if ($this->hasGroup(CMSGroupContext::BLOCKS)) {
            foreach ($site->getBlocks() as $value) {
                $facade->addBlocks($value);
            }
        }

        return $facade;
    }
580608
static function SitemapCacheFile(Site $site)
    {
        $cacheFolder = Path::Combine(PHINE_PATH, 'App/Phine/Cache/Sitemap');
        $filename = Path::AddExtension($site->GetID(), 'xml');
        return Path::Combine($cacheFolder, $filename);
    }
155511
public function setSite($site)
    {
        if ($site === null) {
            $this->siteId = null;
            $this->site = null;

            return;
        }
        $this->siteId = $site->getSiteId();

        $this->site = $site;
    }
1199851
public function save()
    {
        $render = new Renderer($this->configuration);
        $siteInstall = $render->render();
        $render = new Renderer([
            'userEmail' => $this->getUserEmail(),
            'userPasswordHash' => $this->getUserPasswordHash(),
            'startingPointHandle' => $this->getStartingPointHandle(),
            'siteName' => $this->getSiteName(),
            'siteLocaleId' => $this->getSiteLocaleId(),
            'uiLocaleId' => $this->getUiLocaleId(),
            'serverTimeZone' => $this->getServerTimeZoneId(),
            'privacyPolicy' => $this->isPrivacyPolicyAccepted()
        ]);
        $siteInstallUser = $render->render();
        if (@$this->filesystem->put(DIR_CONFIG_SITE . '/site_install.php', $siteInstall) === false) {
            throw new UserMessageException(t('Failed to write to file %s', DIRNAME_APPLICATION . '/' . DIRNAME_CONFIG . '/site_install.php'));
        }
        OpCache::clear(DIR_CONFIG_SITE . '/site_install_user.php');
        if (@$this->filesystem->put(DIR_CONFIG_SITE . '/site_install_user.php', $siteInstallUser) === false) {
            throw new UserMessageException(t('Failed to write to file %s', DIRNAME_APPLICATION . '/' . DIRNAME_CONFIG . '/site_install_user.php'));
        }
        OpCache::clear(DIR_CONFIG_SITE . '/site_install_user.php');
    }
817854
public function setSite(\BlackForest\PiwikBundle\Entity\PiwikSite $site = null)
    {
        $this->site = $site;

        return $this;
    }
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;
    }
433542
protected function setBaseUrl($site): self
    {
        $this->baseUrl = sprintf($this->baseUrl, $site, self::VERSION);

        return $this;
    }
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;
    }