mirror of
https://github.com/envoyr/nginx-configurator.git
synced 2026-04-28 12:24:08 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cb2b55b936 | |||
| eeb85df689 | |||
| a66ae2c266 |
@@ -46,7 +46,7 @@ class Location extends Context
|
|||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
return sprintf(
|
return sprintf(
|
||||||
"{$this->name} %s %s {\n\t%s\n}\n",
|
"{$this->name} %s %s {\n\t%s\n}",
|
||||||
$this->match,
|
$this->match,
|
||||||
$this->location,
|
$this->location,
|
||||||
implode("\n\t", (array)$this->childNodes->getIterator())
|
implode("\n\t", (array)$this->childNodes->getIterator())
|
||||||
|
|||||||
49
src/Config/Raw.php
Normal file
49
src/Config/Raw.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: envoyr
|
||||||
|
* Date: 04.01.25
|
||||||
|
* Time: 16:29
|
||||||
|
*/
|
||||||
|
namespace Envoyr\NginxConfigurator\Config;
|
||||||
|
|
||||||
|
use Envoyr\NginxConfigurator\Node\Context;
|
||||||
|
use Envoyr\NginxConfigurator\Node\Literal;
|
||||||
|
use Envoyr\NginxConfigurator\Node\Node;
|
||||||
|
use Envoyr\NginxConfigurator\Node\Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class Raw
|
||||||
|
* @package Envoyr\NginxConfigurator\Config
|
||||||
|
* @author Maurice Preuß <hello@envoyr.com>
|
||||||
|
*/
|
||||||
|
class Raw extends Node
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Holds raw string
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $raw;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Raw constructor.
|
||||||
|
* @param string $raw
|
||||||
|
*/
|
||||||
|
public function __construct(string $raw)
|
||||||
|
{
|
||||||
|
$this->raw = $raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __toString() : string
|
||||||
|
{
|
||||||
|
return $this->raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getRaw() : string
|
||||||
|
{
|
||||||
|
return (string)$this->raw;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,12 +16,13 @@ class Factory
|
|||||||
/**
|
/**
|
||||||
* Creates Server node
|
* Creates Server node
|
||||||
* @param int $port
|
* @param int $port
|
||||||
|
* @param array $additionalParams
|
||||||
* @return Server
|
* @return Server
|
||||||
*/
|
*/
|
||||||
public function createServer(int $port = 80) : Server
|
public function createServer(int $port = 80, array $additionalParams = []) : Server
|
||||||
{
|
{
|
||||||
$listenIPv4 = new Directive('listen', [new Param($port)]);
|
$listenIPv4 = new Directive('listen', [new Param($port), ...$additionalParams]);
|
||||||
$listenIPv6 = new Directive('listen', [new Param("[::]:{$port}")]);
|
$listenIPv6 = new Directive('listen', [new Param("[::]:{$port}"), ...$additionalParams]);
|
||||||
|
|
||||||
return new Server([$listenIPv4, $listenIPv6]);
|
return new Server([$listenIPv4, $listenIPv6]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user