Format code using php-cs-fixer
This commit is contained in:
parent
43d7dc92cd
commit
d52c6184b9
352 changed files with 17473 additions and 17041 deletions
|
@ -2,75 +2,83 @@
|
|||
|
||||
/**
|
||||
* User: sourcefabric
|
||||
* Date: 02/12/14
|
||||
* Date: 02/12/14.
|
||||
*
|
||||
* Class RabbitMQSetup
|
||||
*
|
||||
* Wrapper class for validating and setting up RabbitMQ during the installation process
|
||||
*/
|
||||
class RabbitMQSetup extends Setup {
|
||||
|
||||
class RabbitMQSetup extends Setup
|
||||
{
|
||||
// airtime.conf section header
|
||||
protected static $_section = "[rabbitmq]";
|
||||
protected static $_section = '[rabbitmq]';
|
||||
|
||||
// Array of key->value pairs for airtime.conf
|
||||
protected static $_properties;
|
||||
|
||||
// Constant form field names for passing errors back to the front-end
|
||||
const RMQ_USER = "rmqUser",
|
||||
RMQ_PASS = "rmqPass",
|
||||
RMQ_PORT = "rmqPort",
|
||||
RMQ_HOST = "rmqHost",
|
||||
RMQ_VHOST = "rmqVHost";
|
||||
public const RMQ_USER = 'rmqUser';
|
||||
public const RMQ_PASS = 'rmqPass';
|
||||
public const RMQ_PORT = 'rmqPort';
|
||||
public const RMQ_HOST = 'rmqHost';
|
||||
public const RMQ_VHOST = 'rmqVHost';
|
||||
|
||||
// Message and error fields to return to the front-end
|
||||
static $message = null;
|
||||
static $errors = array();
|
||||
public static $message;
|
||||
public static $errors = [];
|
||||
|
||||
function __construct($settings) {
|
||||
static::$_properties = array(
|
||||
"host" => $settings[self::RMQ_HOST],
|
||||
"port" => $settings[self::RMQ_PORT],
|
||||
"user" => $settings[self::RMQ_USER],
|
||||
"password" => $settings[self::RMQ_PASS],
|
||||
"vhost" => $settings[self::RMQ_VHOST],
|
||||
);
|
||||
public function __construct($settings)
|
||||
{
|
||||
static::$_properties = [
|
||||
'host' => $settings[self::RMQ_HOST],
|
||||
'port' => $settings[self::RMQ_PORT],
|
||||
'user' => $settings[self::RMQ_USER],
|
||||
'password' => $settings[self::RMQ_PASS],
|
||||
'vhost' => $settings[self::RMQ_VHOST],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array associative array containing a display message and fields with errors
|
||||
*/
|
||||
function runSetup() {
|
||||
public function runSetup()
|
||||
{
|
||||
try {
|
||||
if ($this->checkRMQConnection()) {
|
||||
self::$message = "Connection successful!";
|
||||
self::$message = 'Connection successful!';
|
||||
} else {
|
||||
$this->identifyRMQConnectionError();
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->identifyRMQConnectionError();
|
||||
}
|
||||
return array(
|
||||
"message" => self::$message,
|
||||
"errors" => self::$errors
|
||||
);
|
||||
|
||||
return [
|
||||
'message' => self::$message,
|
||||
'errors' => self::$errors,
|
||||
];
|
||||
}
|
||||
|
||||
function checkRMQConnection() {
|
||||
$conn = new \PhpAmqpLib\Connection\AMQPConnection(self::$_properties["host"],
|
||||
self::$_properties["port"],
|
||||
self::$_properties["user"],
|
||||
self::$_properties["password"],
|
||||
self::$_properties["vhost"]);
|
||||
public function checkRMQConnection()
|
||||
{
|
||||
$conn = new \PhpAmqpLib\Connection\AMQPConnection(
|
||||
self::$_properties['host'],
|
||||
self::$_properties['port'],
|
||||
self::$_properties['user'],
|
||||
self::$_properties['password'],
|
||||
self::$_properties['vhost']
|
||||
);
|
||||
$this->writeToTemp();
|
||||
|
||||
return isset($conn);
|
||||
}
|
||||
|
||||
function identifyRMQConnectionError() {
|
||||
public function identifyRMQConnectionError()
|
||||
{
|
||||
// It's impossible to identify errors coming out of amqp.inc without a major
|
||||
// rewrite, so for now just tell the user ALL THE THINGS went wrong
|
||||
self::$message = _("Couldn't connect to RabbitMQ server! Please check if the server "
|
||||
. "is running and your credentials are correct.");
|
||||
. 'is running and your credentials are correct.');
|
||||
self::$errors[] = self::RMQ_USER;
|
||||
self::$errors[] = self::RMQ_PASS;
|
||||
self::$errors[] = self::RMQ_HOST;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue