/**
  * @return bool
  */
 protected function isAuthenticated()
 {
     if ($this->name === NULL || $this->password === NULL) {
         return FALSE;
     }
     $httpAuthentication = Configuration::getSection('phpframework', 'authentication.http');
     if (!array_key_exists($this->name, $httpAuthentication)) {
         return FALSE;
     }
     return sha1($this->password) === $httpAuthentication[$this->name];
 }
 /**
  * Connects to the MySQL server, sets the charset for the connection and
  * selects the database
  */
 public function connect()
 {
     if (!$this->connection instanceof \PDO) {
         $dbConfiguration = Configuration::getSection('phpframework', 'db');
         $dsn = 'mysql:host=' . $dbConfiguration['mysql.host'] . ';dbname=' . $dbConfiguration['mysql.database'];
         $this->connection = new \PDO($dsn, $dbConfiguration['mysql.user'], $dbConfiguration['mysql.password']);
         if (isset($dbConfiguration['charset'])) {
             $this->setCharset($dbConfiguration['charset']);
         }
     }
 }
 /**
  *
  */
 public static function initialize()
 {
     $airbrake_ini = Configuration::getSection('phpframework-airbrake');
     if (!is_null($airbrake_ini) && Configuration::get('phpframework-airbrake', 'enable', FALSE)) {
         $apiKey = $airbrake_ini['api_key'];
         $airbrake_environment = isset($airbrake_ini['environment']) ? $airbrake_ini['environment'] : 'NO_ENVIRONMENT_SET';
         $options = ['secure' => TRUE, 'host' => $airbrake_ini['host'], 'resource' => $airbrake_ini['resource'], 'timeout' => 10, 'environmentName' => Configuration::get('application', 'application') . ' / ' . $airbrake_environment];
         \Airbrake\EventHandler::start($apiKey, FALSE, $options);
         $config = new \Airbrake\Configuration($apiKey, $options);
         self::$client = new \Airbrake\Client($config);
     }
 }
Example #4
0
 /**
  *
  */
 protected static function loadPlugins()
 {
     $plugins = Configuration::getSection('phpframework', 'plugins');
     if ($plugins) {
         foreach ($plugins as $namespace => $enabled) {
             if ($enabled) {
                 $pluginLoaderClassname = $namespace . '\\PluginLoader';
                 if (!class_exists($pluginLoaderClassname)) {
                     throw new \Exception('Plugin ' . $namespace . ' could not be loaded. Class ' . $pluginLoaderClassname . ' was not found.', 1413322791);
                 }
                 new $pluginLoaderClassname();
             }
         }
     }
     SignalSlotDispatcher::emitSignal(self::SIGNAL_PLUGINSLOADED);
 }
Example #5
0
 /**
  * @return \Swift_Transport
  */
 protected function createTransport()
 {
     $mailConfiguration = Configuration::getSection('phpframework', 'mail', ['smtp_encryption' => 'ssl', 'smtp_host' => 'localhost', 'smtp_password' => '', 'smtp_port' => FALSE, 'smtp_user' => FALSE]);
     if (!$mailConfiguration['smtp_user']) {
         return \Swift_MailTransport::newInstance();
     }
     if ($mailConfiguration['smtp_encryption'] === 'none') {
         $mailConfiguration['smtp_encryption'] = NULL;
     }
     if (!$mailConfiguration['smtp_port']) {
         if ($mailConfiguration['smtp_encryption'] === 'ssl') {
             $mailConfiguration['smtp_port'] = '465';
         } else {
             $mailConfiguration['smtp_port'] = '587';
         }
     }
     $transport = \Swift_SmtpTransport::newInstance($mailConfiguration['smtp_host'], $mailConfiguration['smtp_port'], $mailConfiguration['smtp_encryption']);
     $transport->setUsername($mailConfiguration['smtp_user']);
     $transport->setPassword($mailConfiguration['smtp_password']);
     return $transport;
 }
 /**
  * @test
  */
 public function getSectionDefaultValuesNamespace()
 {
     Configuration::reset();
     Configuration::set('test', 'ns1.key1', 1);
     Configuration::set('test', 'ns2.key2', FALSE);
     Configuration::set('test', 'ns1.key3', 3);
     $configuration = Configuration::getSection('test', 'ns1', ['key1' => FALSE, 'key2' => 2]);
     $this->assertSame(1, $configuration['key1']);
     $this->assertSame(2, $configuration['key2']);
     $this->assertSame(3, $configuration['key3']);
 }