Exemplo n.º 1
0
             throw $e;
         }
         $step = 4;
     }
     break;
 case 4:
     /**
      * sites.yml creation
      * my-wonderful-website:
      *   label: 'My wonderful website'
      *   domain: my.wonderful-website.com
      */
     $application = new \BackBee\Standard\Application();
     if (isset($_POST['site_name']) && isset($_POST['domain']) && filter_var($_POST['domain'], FILTER_VALIDATE_URL) !== false) {
         $em = $application->getEntityManager();
         $pagebuilder = $application->getContainer()->get('pagebuilder');
         $host = parse_url($_POST['domain'], PHP_URL_HOST);
         $port = parse_url($_POST['domain'], PHP_URL_PORT);
         $path = parse_url($_POST['domain'], PHP_URL_PATH);
         $domain = $host . (empty($port) ? '' : ':' . $port) . ($path ?: '');
         $sites = [];
         $sitesPath = realpath(__DIR__ . '/../repository/Config/sites.yml');
         if (file_exists($sitesPath)) {
             $sites = $yaml->parse($sitesPath);
         }
         $label = \BackBee\Utils\StringUtils::urlize($_POST['site_name']);
         if (!isset($sites[$label])) {
             $sites[$label] = [];
         }
         $sites[$label] = ['label' => $_POST['site_name'], 'domain' => $domain];
         file_put_contents(dirname(__DIR__) . '/repository/Config/sites.yml', $yaml->dump($sites));
Exemplo n.º 2
0
         }
         $step = 4;
     }
     break;
 case 4:
     /**
      * sites.yml creation
      * my-wonderful-website:
      *   label: 'My wonderful website'
      *   domain: my.wonderful-website.com
      * if demo_website option is setup, install a complete Website
      */
     $application = new \BackBee\Standard\Application();
     if (isset($_POST['site_name']) && isset($_POST['domain']) && filter_var($_POST['domain'], FILTER_VALIDATE_URL) !== false) {
         $em = $application->getEntityManager();
         $pagebuilder = $application->getContainer()->get('pagebuilder');
         $host = parse_url($_POST['domain'], PHP_URL_HOST);
         $port = parse_url($_POST['domain'], PHP_URL_PORT);
         $domain = $host . (empty($port) ? '' : ':' . $port);
         $sites = [\BackBee\Utils\StringUtils::urlize($_POST['site_name']) => ['label' => $_POST['site_name'], 'domain' => $domain]];
         file_put_contents(dirname(__DIR__) . '/repository/Config/sites.yml', $yaml->dump($sites));
         foreach ($sites as $label => $siteConfig) {
             // Website creation
             if (null === ($site = $em->find('BackBee\\Site\\Site', md5($label)))) {
                 $site = new \BackBee\Site\Site(md5($label));
                 $site->setLabel($label)->setServerName($siteConfig['domain']);
                 $em->persist($site);
                 $em->flush($site);
             }
             $application->getContainer()->set('site', $site);
             if (isset($_POST['demo_website'])) {
Exemplo n.º 3
0
             // to be catched by Debug component
         }
         $step = 4;
     }
     break;
 case 4:
     /**
      * sites.yml creation
      * my-wonderful-website:
      *   label: 'My wonderful website'
      *   domain: my.wonderful-website.com
      */
     $application = new \BackBee\Standard\Application();
     if (isset($_POST['site_name']) && isset($_POST['domain']) && filter_var($_POST['domain'], FILTER_VALIDATE_URL) !== false) {
         $em = $application->getEntityManager();
         $pagebuilder = $application->getContainer()->get('pagebuilder');
         $host = parse_url($_POST['domain'], PHP_URL_HOST);
         $port = parse_url($_POST['domain'], PHP_URL_PORT);
         $domain = $host . (empty($port) ? '' : ':' . $port);
         $sites = [\BackBee\Utils\StringUtils::urlize($_POST['site_name']) => ['label' => $_POST['site_name'], 'domain' => $domain]];
         file_put_contents(dirname(__DIR__) . '/repository/Config/sites.yml', $yaml->dump($sites));
         foreach ($sites as $label => $siteConfig) {
             // Website creation
             if (null === ($site = $em->find('BackBee\\Site\\Site', md5($label)))) {
                 $site = new \BackBee\Site\Site(md5($label));
                 $site->setLabel($label)->setServerName($siteConfig['domain']);
                 $em->persist($site);
                 $em->flush($site);
             }
             $application->getContainer()->set('site', $site);
             // Home layout