Exemplo n.º 1
0
 /**
  * Initializes the website services, based on ini file configuration
  */
 protected function initialize()
 {
     $sections = $this->ini->getSections();
     if (!in_array('main', $sections)) {
         throw new \browserfs\Exception('A [main] section is required in configuration file.');
     }
     $services = $this->ini->getSectionProperties('main');
     if (in_array('staging', $services)) {
         $this->staging = $this->ini->getProperty('main', 'staging', 'development');
         if (!in_array($this->staging, ['development', 'staging', 'production'])) {
             throw new \browserfs\Exception('Bad staging value inside of [main]: allowed "development", "staging", "production"');
         }
     }
     foreach ($services as $serviceName) {
         if (!in_array($sectionName = $serviceName . '.' . $this->staging, $sections)) {
             $sectionName = $serviceName;
         }
         if (!in_array($sectionName, $sections)) {
             throw new \browserfs\Exception('Failed to load service "' . $sectionName . '": An appropriated section for it does not exist in config file!');
         }
         $serviceProperties = [];
         foreach ($this->ini->getSectionProperties($sectionName) as $sectionPropertyName) {
             $serviceProperties[$sectionPropertyName] = $this->ini->getPropertyMulti($sectionName, $sectionPropertyName);
         }
         $service = \browserfs\website\Service::factory($serviceName, $this->ini->getProperty('main', $serviceName, ''), $this->namespace, $serviceProperties);
         $service->setDIInjector($this);
         $this->services[$serviceName] = $service;
     }
 }
Exemplo n.º 2
0
 /**
  * The service "Website" provides us with information about the
  * website we're developing.
  */
 protected function __construct($properties)
 {
     // THIS SHOULD BE THE FIRST INSTRUCTION
     parent::__construct($properties);
     $this->init();
 }
Exemplo n.º 3
0
 protected function __construct($serviceConfig)
 {
     parent::__construct($serviceConfig);
     $this->init();
 }
Exemplo n.º 4
0
 protected function __construct($serviceProperties)
 {
     parent::__construct($serviceProperties);
     $this->init();
 }