sintonia/airtime_mvc/public/setup/general-setup.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2014-12-09 23:48:16 +01:00
<?php
/**
* User: sourcefabric
* Date: 08/12/14
*
* Class GeneralSetup
*
* Wrapper class for validating and setting up general settings during the installation process
*/
class GeneralSetup extends Setup {
// airtime.conf section header
protected static $_section = "[general]";
2014-12-09 23:48:16 +01:00
// Constant form field names for passing errors back to the front-end
const GENERAL_PORT = "generalPort",
GENERAL_HOST = "generalHost";
// Array of key->value pairs for airtime.conf
protected static $_properties;
2014-12-09 23:48:16 +01:00
// Message and error fields to return to the front-end
static $message = null;
static $errors = array();
function __construct($settings) {
self::$_properties = array(
2014-12-09 23:48:16 +01:00
"api_key" => $this->generateRandomString(),
"base_url" => $settings[self::GENERAL_HOST],
"base_port" => $settings[self::GENERAL_PORT],
2014-12-09 23:48:16 +01:00
);
}
/**
* @return array associative array containing a display message and fields with errors
*/
function runSetup() {
2014-12-15 15:53:50 +01:00
// TODO Do we need to validate these settings?
2014-12-09 23:48:16 +01:00
if (count(self::$errors) <= 0) {
$this->writeToTemp();
}
return array(
"message" => self::$message,
"errors" => self::$errors
);
}
}