Example #1
0
 /**
  * Trys to load a site by the requested URI.
  *
  * @return bool
  */
 public function loadSite()
 {
     // Connect database after tring to load the cache
     $this->db->connect();
     $this->initExtensionRoutes();
     $this->db->setUpTranslateable()->setUpSortable();
     if ($menuItem = $this->checkRouteHook()) {
         $this->renderSite(true, $menuItem);
     } else {
         $this->renderSite(true, $this->parseRoute());
     }
 }
Example #2
0
 /**
  * @return array|bool
  */
 protected function initConfigurations()
 {
     $gp = $this->request->getGPAsObject();
     $errors = [];
     /**
      * create default language
      */
     $locale = new \Fraym\Locale\Entity\Locale();
     switch ($gp->locale) {
         case 'german':
             $locale->name = 'German';
             $locale->locale = 'de_DE';
             $locale->country = 'Germany';
             $locale->default = true;
             break;
         case 'french':
             $locale->name = 'French';
             $locale->locale = 'fr_FR';
             $locale->country = 'France';
             $locale->default = true;
             break;
         case 'swedish':
             $locale->name = 'swedish';
             $locale->locale = 'sv_SE';
             $locale->country = 'Sweden';
             $locale->default = true;
             break;
         case 'spanish':
             $locale->name = 'Spanish';
             $locale->locale = 'es_ES';
             $locale->country = 'Spain';
             $locale->default = true;
             break;
         default:
             // english
             $locale->name = 'English';
             $locale->locale = 'en_US';
             $locale->country = 'USA';
             $locale->default = true;
             break;
     }
     $this->db->persist($locale);
     $this->db->flush();
     $this->locale->setLocale($locale);
     $this->db->setUpTranslateable()->setUpSortable();
     /**
      * create site
      */
     $site = new \Fraym\Site\Entity\Site();
     $site->name = $gp->site->name;
     $site->caching = true;
     $site->active = true;
     $site->menuItems->clear();
     $this->db->persist($site);
     /**
      * create domain for site
      */
     $domain = new \Fraym\Site\Entity\Domain();
     $domain->site = $site;
     $domain->address = $gp->site->url;
     $this->db->persist($domain);
     $this->addMenuItems($site);
     $adminGroup = new \Fraym\User\Entity\Group();
     $adminGroup->name = $this->translation->autoTranslation('Administrator', 'en', $this->locale->getLocale()->locale);
     $adminGroup->identifier = 'Administrator';
     $this->db->persist($adminGroup);
     $adminUser = new \Fraym\User\Entity\User();
     $adminUser->updateEntity($gp->user, false);
     if (strlen($gp->user->password) < 8) {
         $errors[] = 'Password is too short.';
     } elseif ($gp->user->password === $gp->user->password_repeat) {
         $adminUser->password = $gp->user->password;
     } else {
         $errors[] = 'Passwords do not match.';
     }
     $adminUser->groups->add($adminGroup);
     $this->db->persist($adminUser);
     if (count($errors) === 0) {
         $this->db->flush();
         $this->db->clear();
         /**
          * Register extensions, default theme...
          */
         $this->registry->registerExtensions();
         /**
          * Set menuitem template -> default theme
          */
         $this->setupMenuItemTemplate();
         /**
          * Login admin user
          */
         $this->user->setUserId($adminUser->id);
         return true;
     }
     return $errors;
 }