Minor adjustments to make configuration easier

This commit is contained in:
Kijin Sung 2016-11-12 15:17:32 +09:00
parent bbd95865c3
commit ddc0da173a
5 changed files with 47 additions and 2 deletions

View file

@ -21,6 +21,7 @@ abstract class Base implements \Rhymix\Framework\Drivers\SMSInterface
* Config keys used by this driver are stored here. * Config keys used by this driver are stored here.
*/ */
protected static $_required_config = array(); protected static $_required_config = array();
protected static $_optional_config = array();
/** /**
* Direct invocation of the constructor is not permitted. * Direct invocation of the constructor is not permitted.
@ -61,6 +62,16 @@ abstract class Base implements \Rhymix\Framework\Drivers\SMSInterface
return static::$_required_config; return static::$_required_config;
} }
/**
* Get the list of configuration fields optionally used by this SMS driver.
*
* @return array
*/
public static function getOptionalConfig()
{
return static::$_optional_config;
}
/** /**
* Get the list of API types supported by this SMS driver. * Get the list of API types supported by this SMS driver.
* *
@ -90,7 +101,7 @@ abstract class Base implements \Rhymix\Framework\Drivers\SMSInterface
*/ */
public static function isSupported() public static function isSupported()
{ {
return true; return false;
} }
/** /**

View file

@ -35,7 +35,20 @@ class CoolSMS extends Base implements \Rhymix\Framework\Drivers\SMSInterface
/** /**
* Config keys used by this driver are stored here. * Config keys used by this driver are stored here.
*/ */
protected static $_required_config = array('api_key', 'api_secret', 'sender_key'); protected static $_required_config = array('api_key', 'api_secret');
protected static $_optional_config = array('sender_key');
/**
* Check if the current SMS driver is supported on this server.
*
* This method returns true on success and false on failure.
*
* @return bool
*/
public static function isSupported()
{
return true;
}
/** /**
* Send a message. * Send a message.

View file

@ -37,6 +37,18 @@ class Dummy extends Base implements \Rhymix\Framework\Drivers\SMSInterface
*/ */
protected $_sent_messages = array(); protected $_sent_messages = array();
/**
* Check if the current SMS driver is supported on this server.
*
* This method returns true on success and false on failure.
*
* @return bool
*/
public static function isSupported()
{
return true;
}
/** /**
* Send a message. * Send a message.
* *

View file

@ -29,6 +29,13 @@ interface SMSInterface
*/ */
public static function getRequiredConfig(); public static function getRequiredConfig();
/**
* Get the list of configuration fields optionally used by this SMS driver.
*
* @return array
*/
public static function getOptionalConfig();
/** /**
* Get the list of API types supported by this SMS driver. * Get the list of API types supported by this SMS driver.
* *

View file

@ -90,6 +90,7 @@ class SMS
$result[$driver_name] = array( $result[$driver_name] = array(
'name' => $class_name::getName(), 'name' => $class_name::getName(),
'required' => $class_name::getRequiredConfig(), 'required' => $class_name::getRequiredConfig(),
'optional' => $class_name::getOptionalConfig(),
'api_types' => $class_name::getAPITypes(), 'api_types' => $class_name::getAPITypes(),
'api_spec' => $class_name::getAPISpec(), 'api_spec' => $class_name::getAPISpec(),
); );
@ -102,6 +103,7 @@ class SMS
$result[strtolower(class_basename($driver))] = array( $result[strtolower(class_basename($driver))] = array(
'name' => $driver->getName(), 'name' => $driver->getName(),
'required' => $driver->getRequiredConfig(), 'required' => $driver->getRequiredConfig(),
'optional' => $driver->getOptionalConfig(),
'api_types' => $driver->getAPITypes(), 'api_types' => $driver->getAPITypes(),
'api_spec' => $class_name::getAPISpec(), 'api_spec' => $class_name::getAPISpec(),
); );