当前位置: 首页>>代码示例>>PHP>>正文


PHP Repository\SiteRepository类代码示例

本文整理汇总了PHP中TYPO3\Neos\Domain\Repository\SiteRepository的典型用法代码示例。如果您正苦于以下问题:PHP SiteRepository类的具体用法?PHP SiteRepository怎么用?PHP SiteRepository使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SiteRepository类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 /**
  * Setup the most commonly used mocks and a real FrontendRoutePartHandler. The mock objects created by this function
  * will not be sufficient for most tests, but they are the lowest common denominator.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->routePartHandler = new FrontendNodeRoutePartHandler();
     $this->routePartHandler->setName('node');
     // The mockContextFactory is configured to return the last mock context which has been built with buildMockContext():
     $mockContextFactory = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactory', array('create'));
     $mockContextFactory->mockContext = null;
     $mockContextFactory->expects($this->any())->method('create')->will($this->returnCallback(function ($contextProperties) use($mockContextFactory) {
         if (isset($contextProperties['currentSite'])) {
             $mockContextFactory->mockContext->mockSite = $contextProperties['currentSite'];
         }
         if (isset($contextProperties['currentDomain'])) {
             $mockContextFactory->mockContext->mockDomain = $contextProperties['currentDomain'];
         }
         if (isset($contextProperties['dimensions'])) {
             $mockContextFactory->mockContext->mockDimensions = $contextProperties['dimensions'];
         }
         if (isset($contextProperties['targetDimensions'])) {
             $mockContextFactory->mockContext->mockTargetDimensions = $contextProperties['targetDimensions'];
         }
         return $mockContextFactory->mockContext;
     }));
     $this->mockContextFactory = $mockContextFactory;
     $this->inject($this->routePartHandler, 'contextFactory', $this->mockContextFactory);
     $this->mockSystemLogger = $this->getMock('TYPO3\\Flow\\Log\\SystemLoggerInterface');
     $this->inject($this->routePartHandler, 'systemLogger', $this->mockSystemLogger);
     $this->mockDomainRepository = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Repository\\DomainRepository')->disableOriginalConstructor()->getMock();
     $this->inject($this->routePartHandler, 'domainRepository', $this->mockDomainRepository);
     $this->mockSiteRepository = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Repository\\SiteRepository')->disableOriginalConstructor()->getMock();
     $this->mockSiteRepository->expects($this->any())->method('findFirstOnline')->will($this->returnValue(null));
     $this->inject($this->routePartHandler, 'siteRepository', $this->mockSiteRepository);
     $this->contentDimensionPresetSource = new ConfigurationContentDimensionPresetSource();
     $this->contentDimensionPresetSource->setConfiguration(array());
     $this->inject($this->routePartHandler, 'contentDimensionPresetSource', $this->contentDimensionPresetSource);
 }
开发者ID:reinis-zumbergs,项目名称:neos-development-collection,代码行数:41,代码来源:FrontendNodeRoutePartHandlerTest.php

示例2: searchForNodeAction

 /**
  * @param string $searchWord
  * @param Site $selectedSite
  * @return void
  */
 public function searchForNodeAction($searchWord, Site $selectedSite = NULL)
 {
     $documentNodeTypes = $this->nodeTypeManager->getSubNodeTypes('TYPO3.Neos:Document');
     $shortcutNodeType = $this->nodeTypeManager->getNodeType('TYPO3.Neos:Shortcut');
     $nodeTypes = array_diff($documentNodeTypes, array($shortcutNodeType));
     $sites = array();
     $activeSites = $this->siteRepository->findOnline();
     foreach ($selectedSite ? array($selectedSite) : $activeSites as $site) {
         /** @var Site $site */
         $contextProperties = array('workspaceName' => 'live', 'currentSite' => $site);
         $contentDimensionPresets = $this->contentDimensionPresetSource->getAllPresets();
         if (count($contentDimensionPresets) > 0) {
             $mergedContentDimensions = array();
             foreach ($contentDimensionPresets as $contentDimensionIdentifier => $contentDimension) {
                 $mergedContentDimensions[$contentDimensionIdentifier] = array($contentDimension['default']);
                 foreach ($contentDimension['presets'] as $contentDimensionPreset) {
                     $mergedContentDimensions[$contentDimensionIdentifier] = array_merge($mergedContentDimensions[$contentDimensionIdentifier], $contentDimensionPreset['values']);
                 }
                 $mergedContentDimensions[$contentDimensionIdentifier] = array_values(array_unique($mergedContentDimensions[$contentDimensionIdentifier]));
             }
             $contextProperties['dimensions'] = $mergedContentDimensions;
         }
         /** @var ContentContext $liveContext */
         $liveContext = $this->contextFactory->create($contextProperties);
         $firstActiveDomain = $site->getFirstActiveDomain();
         $nodes = $this->nodeSearchService->findByProperties($searchWord, $nodeTypes, $liveContext, $liveContext->getCurrentSiteNode());
         if (count($nodes) > 0) {
             $sites[$site->getNodeName()] = array('site' => $site, 'domain' => $firstActiveDomain ? $firstActiveDomain->getHostPattern() : $this->request->getHttpRequest()->getUri()->getHost(), 'nodes' => $nodes);
         }
     }
     $this->view->assignMultiple(array('searchWord' => $searchWord, 'protocol' => $this->request->getHttpRequest()->getUri()->getScheme(), 'selectedSite' => $selectedSite, 'sites' => $sites, 'activeSites' => $activeSites));
 }
开发者ID:christophlehmann,项目名称:MOC.Varnish,代码行数:37,代码来源:VarnishCacheController.php

示例3: buildSiteList

 /**
  * Build a list of sites
  *
  * @param ControllerContext $controllerContext
  * @return array
  */
 public function buildSiteList(ControllerContext $controllerContext)
 {
     $requestUriHost = $controllerContext->getRequest()->getHttpRequest()->getUri()->getHost();
     $domainsFound = false;
     $sites = array();
     foreach ($this->siteRepository->findOnline() as $site) {
         $uri = null;
         $active = false;
         /** @var $site Site */
         if ($site->hasActiveDomains()) {
             $activeHostPatterns = $site->getActiveDomains()->map(function ($domain) {
                 return $domain->getHostPattern();
             })->toArray();
             $active = in_array($requestUriHost, $activeHostPatterns, true);
             if ($active) {
                 $uri = $controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(true)->uriFor('index', array(), 'Backend\\Backend', 'TYPO3.Neos');
             } else {
                 $uri = $controllerContext->getUriBuilder()->reset()->uriFor('switchSite', array('site' => $site), 'Backend\\Backend', 'TYPO3.Neos');
             }
             $domainsFound = true;
         }
         $sites[] = array('name' => $site->getName(), 'nodeName' => $site->getNodeName(), 'uri' => $uri, 'active' => $active);
     }
     if ($domainsFound === false) {
         $uri = $controllerContext->getUriBuilder()->reset()->setCreateAbsoluteUri(true)->uriFor('index', array(), 'Backend\\Backend', 'TYPO3.Neos');
         $sites[0]['uri'] = $uri;
     }
     return $sites;
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:35,代码来源:MenuHelper.php

示例4: nodesCommand

 /**
  * Creates a big collection of node for performance benchmarking
  * @param string $siteNode
  * @param string $preset
  */
 public function nodesCommand($siteNode, $preset)
 {
     if (!isset($this->presets[$preset])) {
         $this->outputLine('Error: Invalid preset');
         $this->quit(1);
     }
     $preset = $this->presets[$preset];
     /** @var Site $currentSite */
     $currentSite = $this->siteRepository->findOneByNodeName($siteNode);
     if ($currentSite === null) {
         $this->outputLine('Error: No site for exporting found');
         $this->quit(1);
     }
     /** @var ContentContext $contentContext */
     $contentContext = $this->createContext($currentSite, 'live');
     $workspace = 'live';
     if ($this->workspaceRepository->findByName($workspace)->count() === 0) {
         $this->outputLine('Workspace "%s" does not exist', array($workspace));
         $this->quit(1);
     }
     /** @var Node $siteNode */
     $siteNode = $contentContext->getCurrentSiteNode();
     if ($siteNode === null) {
         $this->outputLine('Error: No site root node');
         $this->quit(1);
     }
     $preset = new PresetDefinition($siteNode, $preset);
     $generator = new NodesGenerator($preset);
     $generator->generate();
 }
开发者ID:kdambekalns,项目名称:Flowpack.NodeGenerator,代码行数:35,代码来源:GeneratorCommandController.php

示例5: isActive

 public function isActive(NodeInterface $siteNode)
 {
     if ($siteModel = $this->siteRepository->findOneByNodeName($siteNode->getName())) {
         return $siteModel->isOnline();
     }
     throw new \RuntimeException('Could not find a site for the given site node', 1473366137);
 }
开发者ID:neos,项目名称:neos-ui,代码行数:7,代码来源:SitesHelper.php

示例6: addCommand

 /**
  * Add a domain record
  *
  * @param string $siteNodeName The nodeName of the site rootNode, e.g. "neostypo3org"
  * @param string $hostPattern The host pattern to match on, e.g. "neos.typo3.org"
  * @param string $scheme The scheme for linking (http/https)
  * @param integer $port The port for linking (0-49151)
  * @return void
  */
 public function addCommand($siteNodeName, $hostPattern, $scheme = null, $port = null)
 {
     $site = $this->siteRepository->findOneByNodeName($siteNodeName);
     if (!$site instanceof Site) {
         $this->outputLine('<error>No site found with nodeName "%s".</error>', array($siteNodeName));
         $this->quit(1);
     }
     $domains = $this->domainRepository->findByHostPattern($hostPattern);
     if ($domains->count() > 0) {
         $this->outputLine('<error>The host pattern "%s" is not unique.</error>', array($hostPattern));
         $this->quit(1);
     }
     $domain = new Domain();
     if ($scheme !== null) {
         $domain->setScheme($scheme);
     }
     if ($port !== null) {
         $domain->setPort($port);
     }
     $domain->setSite($site);
     $domain->setHostPattern($hostPattern);
     $domainValidator = $this->validatorResolver->getBaseValidatorConjunction(Domain::class);
     $result = $domainValidator->validate($domain);
     if ($result->hasErrors()) {
         foreach ($result->getFlattenedErrors() as $propertyName => $errors) {
             $firstError = array_pop($errors);
             $this->outputLine('<error>Validation failed for "' . $propertyName . '": ' . $firstError . '</error>');
             $this->quit(1);
         }
     }
     $this->domainRepository->add($domain);
     $this->outputLine('Domain created.');
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:42,代码来源:DomainCommandController.php

示例7: pruneAll

 /**
  * Remove all nodes, workspaces, domains and sites.
  *
  * @return void
  */
 public function pruneAll()
 {
     $sites = $this->siteRepository->findAll();
     $this->nodeDataRepository->removeAll();
     $this->workspaceRepository->removeAll();
     $this->domainRepository->removeAll();
     $this->siteRepository->removeAll();
     foreach ($sites as $site) {
         $this->emitSitePruned($site);
     }
 }
开发者ID:hlubek,项目名称:neos-development-collection,代码行数:16,代码来源:SiteService.php

示例8: indexAction

 /**
  * Default action, displays the login screen
  *
  * @param string $username Optional: A username to pre-fill into the username field
  * @param boolean $unauthorized
  * @return void
  */
 public function indexAction($username = null, $unauthorized = false)
 {
     if ($this->securityContext->getInterceptedRequest() || $unauthorized) {
         $this->response->setStatus(401);
     }
     if ($this->authenticationManager->isAuthenticated()) {
         $this->redirect('index', 'Backend\\Backend');
     }
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     $currentSite = $currentDomain !== null ? $currentDomain->getSite() : $this->siteRepository->findFirstOnline();
     $this->view->assignMultiple(array('username' => $username, 'site' => $currentSite));
 }
开发者ID:hlubek,项目名称:neos-development-collection,代码行数:19,代码来源:LoginController.php

示例9: prepareContextProperties

 /**
  * Additionally add the current site and domain to the Context properties.
  *
  * {@inheritdoc}
  */
 protected function prepareContextProperties($workspaceName, \TYPO3\Flow\Property\PropertyMappingConfigurationInterface $configuration = null, array $dimensions = null)
 {
     $contextProperties = parent::prepareContextProperties($workspaceName, $configuration, $dimensions);
     $currentDomain = $this->domainRepository->findOneByActiveRequest();
     if ($currentDomain !== null) {
         $contextProperties['currentSite'] = $currentDomain->getSite();
         $contextProperties['currentDomain'] = $currentDomain;
     } else {
         $contextProperties['currentSite'] = $this->siteRepository->findFirstOnline();
     }
     return $contextProperties;
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:17,代码来源:NodeConverter.php

示例10: importSite

 /**
  * @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext
  * @return void
  * @throws \TYPO3\Setup\Exception
  */
 public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext)
 {
     $formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues();
     if (isset($formValues['prune']) && intval($formValues['prune']) === 1) {
         $this->nodeDataRepository->removeAll();
         $this->workspaceRepository->removeAll();
         $this->domainRepository->removeAll();
         $this->siteRepository->removeAll();
         $this->persistenceManager->persistAll();
     }
     if (!empty($formValues['packageKey'])) {
         if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) {
             throw new \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486);
         }
         $packageKey = $formValues['packageKey'];
         $siteName = $formValues['siteName'];
         $generatorService = $this->objectManager->get('TYPO3\\Neos\\Kickstarter\\Service\\GeneratorService');
         $generatorService->generateSitePackage($packageKey, $siteName);
     } elseif (!empty($formValues['site'])) {
         $packageKey = $formValues['site'];
     }
     $this->deactivateOtherSitePackages($packageKey);
     $this->packageManager->activatePackage($packageKey);
     if (!empty($packageKey)) {
         try {
             $contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
             $this->siteImportService->importFromPackage($packageKey, $contentContext);
         } catch (\Exception $exception) {
             $finisherContext->cancel();
             $this->systemLogger->logException($exception);
             throw new SetupException(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()), 1351000864);
         }
     }
 }
开发者ID:radmiraal,项目名称:neos-development-collection,代码行数:39,代码来源:SiteImportStep.php

示例11: uploadAssetAction

 /**
  * Upload a new image, and return its metadata.
  *
  * Depending on the $metadata argument it will return asset metadata for the AssetEditor
  * or image metadata for the ImageEditor
  *
  * @param Asset $asset
  * @param string $metadata Type of metadata to return ("Asset" or "Image")
  * @return string
  */
 public function uploadAssetAction(Asset $asset, $metadata)
 {
     $this->response->setHeader('Content-Type', 'application/json');
     /** @var Site $currentSite */
     $currentSite = $this->siteRepository->findOneByNodeName($this->request->getInternalArgument('__siteNodeName'));
     if ($currentSite !== null && $currentSite->getAssetCollection() !== null) {
         $currentSite->getAssetCollection()->addAsset($asset);
         $this->assetCollectionRepository->update($currentSite->getAssetCollection());
     }
     switch ($metadata) {
         case 'Asset':
             $result = $this->getAssetProperties($asset);
             if ($this->persistenceManager->isNewObject($asset)) {
                 $this->assetRepository->add($asset);
             }
             break;
         case 'Image':
             $result = $this->getImageInterfacePreviewData($asset);
             if ($this->persistenceManager->isNewObject($asset)) {
                 $this->imageRepository->add($asset);
             }
             break;
         default:
             $this->response->setStatus(400);
             $result = array('error' => 'Invalid "metadata" type: ' . $metadata);
     }
     return json_encode($result);
 }
开发者ID:robertlemke,项目名称:neos-development-collection,代码行数:38,代码来源:ContentController.php

示例12: getCurrentSite

 /**
  * Prevents invalid calls to the site respository in case the site data property is not available.
  *
  * @return null|object
  */
 protected function getCurrentSite()
 {
     if (!isset($this->data['site']) || $this->data['site'] === null) {
         return null;
     }
     return $this->siteRepository->findByIdentifier($this->data['site']);
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:12,代码来源:NodeEvent.php

示例13: deactivateSiteAction

 /**
  * Deactivates a site
  *
  * @param Site $site Site to deactivate
  * @return void
  */
 public function deactivateSiteAction(Site $site)
 {
     $site->setState($site::STATE_OFFLINE);
     $this->siteRepository->update($site);
     $this->addFlashMessage('The site "%s" has been deactivated.', 'Site deactivated', Message::SEVERITY_OK, array(htmlspecialchars($site->getName())), 1412372975);
     $this->unsetLastVisitedNodeAndRedirect('index');
 }
开发者ID:sbruggmann,项目名称:neos-development-collection,代码行数:13,代码来源:SitesController.php

示例14: listCommand

 /**
  * Display a list of available sites
  *
  * @return void
  */
 public function listCommand()
 {
     $sites = $this->siteRepository->findAll();
     if ($sites->count() === 0) {
         $this->outputLine('No sites available');
         $this->quit(0);
     }
     $longestSiteName = 4;
     $longestNodeName = 9;
     $longestSiteResource = 17;
     $availableSites = array();
     foreach ($sites as $site) {
         /** @var \TYPO3\Neos\Domain\Model\Site $site */
         array_push($availableSites, array('name' => $site->getName(), 'nodeName' => $site->getNodeName(), 'siteResourcesPackageKey' => $site->getSiteResourcesPackageKey()));
         if (strlen($site->getName()) > $longestSiteName) {
             $longestSiteName = strlen($site->getName());
         }
         if (strlen($site->getNodeName()) > $longestNodeName) {
             $longestNodeName = strlen($site->getNodeName());
         }
         if (strlen($site->getSiteResourcesPackageKey()) > $longestSiteResource) {
             $longestSiteResource = strlen($site->getSiteResourcesPackageKey());
         }
     }
     $this->outputLine();
     $this->outputLine(' ' . str_pad('Name', $longestSiteName + 15) . str_pad('Node name', $longestNodeName + 15) . 'Resources package');
     $this->outputLine(str_repeat('-', $longestSiteName + $longestNodeName + $longestSiteResource + 15 + 15 + 2));
     foreach ($availableSites as $site) {
         $this->outputLine(' ' . str_pad($site['name'], $longestSiteName + 15) . str_pad($site['nodeName'], $longestNodeName + 15) . $site['siteResourcesPackageKey']);
     }
     $this->outputLine();
 }
开发者ID:mgoldbeck,项目名称:neos-development-collection,代码行数:37,代码来源:SiteCommandController.php

示例15: deleteAssetCollectionAction

 /**
  * @param AssetCollection $assetCollection
  * @return void
  */
 public function deleteAssetCollectionAction(AssetCollection $assetCollection)
 {
     foreach ($this->siteRepository->findByAssetCollection($assetCollection) as $site) {
         $site->setAssetCollection(null);
         $this->siteRepository->update($site);
     }
     parent::deleteAssetCollectionAction($assetCollection);
 }
开发者ID:aertmann,项目名称:neos-development-collection,代码行数:12,代码来源:AssetController.php


注:本文中的TYPO3\Neos\Domain\Repository\SiteRepository类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。