Ejemplo n.º 1
0
  *   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'])) {
             $fixtureLoader = $application->getContainer()->get('demo.website_loader');
             /* 1 - load fixtures */
             $dumpFile = $application->getBundle('demo')->getBaseDirectory() . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR . 'Fixtures' . DIRECTORY_SEPARATOR . 'the_mag.sql';
             $fixtureLoader->loadFixtures($dumpFile);
             /* 2 - update website domain and label */
             $label = $_POST['site_name'];
             $fixtureLoader->updateWebsite(['domain' => $domain, 'label' => $label]);
             /* 3 - import pictures assets */
             $applicationMediaRepository = $application->getDataDir() . DIRECTORY_SEPARATOR . 'Media';
Ejemplo n.º 2
0
 /**
  * Create new site db entry
  *
  * @param  string   $siteLabel      Site label
  * @param  string   $siteDomain     Site domain
  *
  * @return \BackBee\Site\Site
  */
 private function createSite($siteLabel, $siteDomain)
 {
     $site = new \BackBee\Site\Site(md5($this->siteLabel));
     $site->setLabel($siteLabel)->setServerName($siteDomain);
     $this->entyMgr->persist($site);
     $this->entyMgr->flush($site);
     return $site;
 }