public function generate()
 {
     $upstreams = $this->upstreamRepository->findAllEnabled();
     foreach ($upstreams as $upstream) {
         $serverScope = Scope::create();
         foreach ($upstream->getServers() as $server) {
             /** @var Server $server */
             $serverScope->addDirective(Directive::create('server', $server->getUrl()));
         }
         $config = Directive::create('upstream', $this->transformString($upstream->getNode()->getTitle()))->setChildScope($serverScope);
         $this->writer->write('upstream', $upstream->getNode()->getTitle(), (string) $config);
     }
 }
 public function generate()
 {
     $sites = $this->siteRepository->findAllEnabled();
     foreach ($sites as $site) {
         /** @var Site $site */
         if (!$site->getUrls()->count()) {
             //TODO log
             continue;
         }
         $urls = array_map(function (SiteUrl $url) {
             return $url->getUrl();
         }, $site->getUrls()->toArray());
         $config = Directive::create('server')->setChildScope(Scope::create()->addDirective(Directive::create('listen', 80))->addDirective(Directive::create('server_name', implode(' ', $urls)))->addDirective(Directive::create('location', '/', Scope::create()->addDirective(Directive::create('proxy_pass', 'http://' . $this->transformString($site->getUpstream()->getNode()->getTitle()))))));
         $this->writer->write('vhost', $site->getNode()->getTitle(), (string) $config);
     }
 }