This a a rather large commit due to the nature of the stuff it is touching. To get PHPUnit up and running again I had to update some deps and I did so by vendorizing them. The vendorizing of zf1 makes sense since distros are already considering to drop it from their repos. * [x] install vendorized zf1 with composer * [x] load composer autoloader before zf1 * [x] Implement headAction for all Zend_Rest_Controller based controllers * [x] switch to yml dataset to get around string only limitations of xml sets (also removed warning in readme) * [x] use year 2044 as hardcoded date for tests since it is in the future and has the same days like previously used 2016 * [x] make tests easier to run when accessing phpunit directly * [x] clean up test helper to always use airtime.conf * [x] switch test dbname to libretime_test * [x] test db username password switched to libretime/libretime * [x] install phpunit with composer in a clear version (make tests easier to reproduce on other platforms) * [x] remove local libs from airtime repo (most of airtime_mvc/library was not needed of in vendor already) * [x] configure composer autoloading and use it (also removed requires that are not needed anymore) * [x] add LibreTime prefix for FileNotFoundException (phing had a similar class and these are all pre-namespace style) * [x] add .travis.yml file * [x] make etc and logdir configurable with LIBRETIME_CONF_DIR and LIBRETIME_LOG_DIR env (so travis can change it) * [x] slight cleanup in config for travis not to fail * [x] add cloud_storage.conf for during test runs * [x] rewrite mvc testing docs and move them to docs/ folder * [x] don't use `static::class` in a class that does not have a parent class, use `__CLASS__` instead. * [x] don't use `<ClassName>::class`, since we already know what class we want `"<ClassName>"` ist just fine. * [x] fix "can't use method in write context" errors on 5.4 (also helps the optimizer) * [x] add build status badge on main README.md Fixes https://github.com/LibreTime/libretime/issues/4 The PHP parts of https://github.com/LibreTime/libretime/pull/10 get obsoleted by this change and it will need rebasing. This also contains https://github.com/LibreTime/libretime/pull/8, the late static binding compat code was broken for no reason and until CentOS drops php 5.4 there is no reason I'm aware of not to support it. I inlined #8 since the test would be failing on php 5.4 without the change. If you want to run tests you need to run `composer install` in the root directory and then `cd airtime_mvc/tests && ../../vendor/bin/phpunit`. For the tests to run the user `libretime` needs to be allowed to create the `libretime_test` database. See `docs/TESTING.md` for more info on getting set up.
123 lines
5.6 KiB
PHP
123 lines
5.6 KiB
PHP
<?php
|
|
/* THIS FILE IS NOT MEANT FOR CUSTOMIZING.
|
|
* PLEASE EDIT THE FOLLOWING TO CHANGE YOUR CONFIG:
|
|
* LIBRETIME_CONF_DIR/airtime.conf
|
|
*/
|
|
|
|
require_once __DIR__ . '/constants.php';
|
|
|
|
class Config {
|
|
private static $CC_CONFIG = null;
|
|
private static $rootDir;
|
|
public static function loadConfig() {
|
|
|
|
self::$rootDir = __DIR__."/../..";
|
|
$CC_CONFIG = array(
|
|
/* ================================================ storage configuration */
|
|
"rootDir" => self::$rootDir
|
|
);
|
|
|
|
//In the unit testing environment, we always want to use our local airtime.conf in airtime_mvc/application/test:
|
|
if (getenv('AIRTIME_UNIT_TEST') == '1') {
|
|
$filename = "airtime.conf";
|
|
} else {
|
|
$filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : LIBRETIME_CONF_DIR . "/airtime.conf";
|
|
}
|
|
|
|
$values = parse_ini_file($filename, true);
|
|
|
|
// Name of the web server user
|
|
$CC_CONFIG['webServerUser'] = $values['general']['web_server_user'];
|
|
$CC_CONFIG['rabbitmq'] = $values['rabbitmq'];
|
|
|
|
$CC_CONFIG['baseDir'] = $values['general']['base_dir'];
|
|
$CC_CONFIG['baseUrl'] = $values['general']['base_url'];
|
|
$CC_CONFIG['basePort'] = $values['general']['base_port'];
|
|
$CC_CONFIG['stationId'] = $values['general']['station_id'];
|
|
$CC_CONFIG['phpDir'] = $values['general']['airtime_dir'];
|
|
if (isset($values['general']['dev_env'])) {
|
|
$CC_CONFIG['dev_env'] = $values['general']['dev_env'];
|
|
} else {
|
|
$CC_CONFIG['dev_env'] = 'production';
|
|
}
|
|
|
|
//Backported static_base_dir default value into saas for now.
|
|
if (array_key_exists('static_base_dir', $values['general'])) {
|
|
$CC_CONFIG['staticBaseDir'] = $values['general']['static_base_dir'];
|
|
} else {
|
|
$CC_CONFIG['staticBaseDir'] = '/';
|
|
}
|
|
|
|
// Parse separate conf file for cloud storage values
|
|
$cloudStorageConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/cloud_storage.conf";
|
|
if (!file_exists($cloudStorageConfig)) {
|
|
// If the dev env specific cloud_storage.conf doesn't exist default
|
|
// to the production cloud_storage.conf
|
|
$cloudStorageConfig = LIBRETIME_CONF_DIR . "/production/cloud_storage.conf";
|
|
}
|
|
$cloudStorageValues = parse_ini_file($cloudStorageConfig, true);
|
|
|
|
$CC_CONFIG["supportedStorageBackends"] = array('amazon_S3');
|
|
foreach ($CC_CONFIG["supportedStorageBackends"] as $backend) {
|
|
$CC_CONFIG[$backend] = $cloudStorageValues[$backend];
|
|
}
|
|
|
|
// Tells us where file uploads will be uploaded to.
|
|
// It will either be set to a cloud storage backend or local file storage.
|
|
$CC_CONFIG["current_backend"] = $cloudStorageValues["current_backend"]["storage_backend"];
|
|
|
|
$CC_CONFIG['cache_ahead_hours'] = $values['general']['cache_ahead_hours'];
|
|
|
|
// Database config
|
|
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
|
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
|
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
|
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
|
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
|
|
|
$CC_CONFIG['apiKey'] = array($values['general']['api_key']);
|
|
|
|
if (defined('APPLICATION_ENV') && APPLICATION_ENV == "development"){
|
|
$CC_CONFIG['apiKey'][] = "";
|
|
}
|
|
|
|
$CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries'];
|
|
$CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries'];
|
|
|
|
$globalAirtimeConfig = LIBRETIME_CONF_DIR . '/' . $CC_CONFIG['dev_env']."/airtime.conf";
|
|
if (!file_exists($globalAirtimeConfig)) {
|
|
// If the dev env specific airtime.conf doesn't exist default
|
|
// to the production airtime.conf
|
|
$globalAirtimeConfig = LIBRETIME_CONF_DIR . "/production/airtime.conf";
|
|
}
|
|
$globalAirtimeConfigValues = parse_ini_file($globalAirtimeConfig, true);
|
|
$CC_CONFIG['soundcloud-client-id'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_id'];
|
|
$CC_CONFIG['soundcloud-client-secret'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_client_secret'];
|
|
$CC_CONFIG['soundcloud-redirect-uri'] = $globalAirtimeConfigValues['soundcloud']['soundcloud_redirect_uri'];
|
|
if (isset($globalAirtimeConfigValues['facebook']['facebook_app_id'])) {
|
|
$CC_CONFIG['facebook-app-id'] = $globalAirtimeConfigValues['facebook']['facebook_app_id'];
|
|
$CC_CONFIG['facebook-app-url'] = $globalAirtimeConfigValues['facebook']['facebook_app_url'];
|
|
$CC_CONFIG['facebook-app-api-key'] = $globalAirtimeConfigValues['facebook']['facebook_app_api_key'];
|
|
}
|
|
|
|
|
|
if(isset($values['demo']['demo'])){
|
|
$CC_CONFIG['demo'] = $values['demo']['demo'];
|
|
}
|
|
self::$CC_CONFIG = $CC_CONFIG;
|
|
}
|
|
|
|
public static function setAirtimeVersion() {
|
|
$airtime_version = Application_Model_Preference::GetAirtimeVersion();
|
|
$uniqueid = Application_Model_Preference::GetUniqueId();
|
|
$buildVersion = @file_get_contents(self::$rootDir."/../VERSION");
|
|
self::$CC_CONFIG['airtime_version'] = md5($airtime_version.$buildVersion);
|
|
}
|
|
|
|
public static function getConfig() {
|
|
if (is_null(self::$CC_CONFIG)) {
|
|
self::loadConfig();
|
|
}
|
|
return self::$CC_CONFIG;
|
|
}
|
|
}
|