getCurrentSite() public method

Returns the current site from this frontend context
public getCurrentSite ( ) : Site
return Neos\Neos\Domain\Model\Site The current site
 /**
  * If the node is not found, we *first* want to figure out whether the node exists in other dimensions or is really non-existent
  *
  * @param $identifier
  * @param ContentContext $context
  * @return void
  */
 protected function addExistingNodeVariantInformationToResponse($identifier, ContentContext $context)
 {
     $nodeVariants = $context->getNodeVariantsByIdentifier($identifier);
     if (count($nodeVariants) > 0) {
         $this->response->setHeader('X-Neos-Node-Exists-In-Other-Dimensions', true);
         // If the node exists in another dimension, we want to know how many nodes in the rootline are also missing for the target
         // dimension. This is needed in the UI to tell the user if nodes will be materialized recursively upwards in the rootline.
         // To find the node path for the given identifier, we just use the first result. This is a safe assumption at least for
         // "Document" nodes (aggregate=TRUE), because they are always moved in-sync.
         $node = reset($nodeVariants);
         /** @var NodeInterface $node */
         if ($node->getNodeType()->isAggregate()) {
             $pathSegmentsToSites = NodePaths::getPathDepth(SiteService::SITES_ROOT_PATH);
             $pathSegmentsToNodeVariant = NodePaths::getPathDepth($node->getPath());
             // Segments between the sites root "/sites" and the node variant (minimum 1)
             $pathSegments = $pathSegmentsToNodeVariant - $pathSegmentsToSites;
             // Nodes between (and including) the site root node and the node variant (minimum 1)
             $siteNodePath = NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $context->getCurrentSite()->getNodeName());
             $nodes = $context->getNodesOnPath($siteNodePath, $node->getPath());
             $missingNodesOnRootline = $pathSegments - count($nodes);
             if ($missingNodesOnRootline > 0) {
                 $this->response->setHeader('X-Neos-Nodes-Missing-On-Rootline', $missingNodesOnRootline);
             }
         }
     }
 }
 /**
  * Collects all hostnames from the Domain entries attached to the current site.
  *
  * @param ContentContext $contentContext
  * @return array
  */
 protected function getHostnames(ContentContext $contentContext)
 {
     $site = $contentContext->getCurrentSite();
     $domains = [];
     if ($site !== null) {
         foreach ($site->getActiveDomains() as $domain) {
             /** @var Domain $domain */
             $domains[] = $domain->getHostname();
         }
     }
     return $domains;
 }