Example #1
0
 /**
  * Init all projects defined
  * in the config
  */
 protected final function initProjects()
 {
     $projects = $this->config->getElementByPath('projects');
     if ($projects) {
         $activeCount = 0;
         foreach ($projects->getChildren() as $proj) {
             /**
              * Collect necessary informations
              * from the xml element frame
              */
             $id = $proj->getName();
             $name = $proj->getChildByName('name');
             $description = $proj->getChildByName('description');
             $namespace = $proj->getChildByName('namespace');
             /**
              * Add a new project to the list
              * with the information from
              * the xml config element
              */
             if (!empty($id) && $name && $description) {
                 $project = ProjectManager::addProject($id, $name->getContent(), $description->getContent(), $namespace->getContent());
                 /**
                  * Check if the project is initial
                  * activated and set the flag
                  * as if is so
                  */
                 $isActive = $project->setActive(filter_var($proj->getAttribute('active'), FILTER_VALIDATE_BOOLEAN));
                 if ($isActive) {
                     $activeCount++;
                     if ($activeCount > 1) {
                         // Init environment types manually
                         $this->initEnvironmentTypes();
                         throw new Bootstrap\Exception\TooManyProjectsException('Only one project can be active');
                     } else {
                         // Add config files from this project
                         Config::getInstance()->addConfigFiles(array(array('dir' => $project->getConfigPath(), 'type' => 'xml')));
                         Router::getInstance()->update();
                     }
                 }
             }
         }
     }
 }