Neos.Neos/Classes/Command/DomainCommandController.php
public function addCommand($siteNodeName, $hostname, $scheme = null, $port = null)
    {
        $site = $this->siteRepository->findOneByNodeName($siteNodeName);
        if (!$site instanceof Site) {
            $this->outputLine('<error>No site found with nodeName "%s".</error>', [$siteNodeName]);
            $this->quit(1);
        }

        $domains = $this->domainRepository->findByHostname($hostname);
        if ($domains->count() > 0) {
            $this->outputLine('<error>The host name "%s" is not unique.</error>', [$hostname]);
            $this->quit(1);
        }

        $domain = new Domain();
        if ($scheme !== null) {
            $domain->setScheme($scheme);
        }
        if ($port !== null) {
            $domain->setPort($port);
        }
        $domain->setSite($site);
        $domain->setHostname($hostname);

        $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 entry created.');
    }
public function addCommand($siteNodeName, $hostname, $scheme = null, $port = null)
    {
        $site = $this->siteRepository->findOneByNodeName($siteNodeName);
        if (!$site instanceof Site) {
            $this->outputLine('<error>No site found with nodeName "%s".</error>', [$siteNodeName]);
            $this->quit(1);
        }

        $domains = $this->domainRepository->findByHostname($hostname);
        if ($domains->count() > 0) {
            $this->outputLine('<error>The host name "%s" is not unique.</error>', [$hostname]);
            $this->quit(1);
        }

        $domain = new Domain();
        if ($scheme !== null) {
            $domain->setScheme($scheme);
        }
        if ($port !== null) {
            $domain->setPort($port);
        }
        $domain->setSite($site);
        $domain->setHostname($hostname);

        $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 entry created.');
    }
public function addCommand ( $ siteNodeName , $ hostname , $ scheme = null , $ port = null ) { $ site = $ this -> siteRepository -> findOneByNodeName ( $ siteNodeName ) ; if ( ! $ site instanceof Site ) { $ this -> outputLine ( '<error>No site found with nodeName "%s".</error>' , [ $ siteNodeName ] ) ; $ this -> quit ( 1 ) ; } $ domains = $ this -> domainRepository -> findByHostname ( $ hostname ) ; if ( $ domains -> count ( ) > 0 ) { $ this -> outputLine ( '<error>The host name "%s" is not unique.</error>' , [ $ hostname ] ) ; $ this -> quit ( 1 ) ; } $ domain = new Domain ( ) ; if ( $ scheme !== null ) { $ domain -> setScheme ( $ scheme ) ; } if ( $ port !== null ) { $ domain -> setPort ( $ port ) ; } $ domain -> setSite ( $ site ) ; $ domain -> setHostname ( $ hostname ) ; $ 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 entry created.' ) ; }
Add a domain record

@param string $siteNodeName The nodeName of the site rootNode, e.g. "flowneosio"
@param string $hostname The hostname to match on, e.g. "flow.neos.io"
@param string $scheme The scheme for linking (http/https)
@param integer $port The port for linking (0-49151)
@return void
Add a domain record