Skip to content
Snippets Groups Projects
Commit b13b5c19 authored by Peter Rotich's avatar Peter Rotich
Browse files

Add format param to PersonsName constructor

Accept desired $format as part of class instantiation. System default is
used when none or an invalid format is provided
parent 90e251f5
No related branches found
No related tags found
No related merge requests found
......@@ -286,6 +286,7 @@ class User extends UserModel {
User::_inspect();
class PersonsName {
var $format;
var $parts;
var $name;
......@@ -302,7 +303,14 @@ class PersonsName {
'original' => array('-- As Entered --', 'getOriginal'),
);
function __construct($name) {
function __construct($name, $format=null) {
global $cfg;
if ($format && !isset(static::$formats[$format]))
$this->format = $format;
elseif($cfg)
$this->format = $cfg->getDefaultNameFormat();
$this->parts = static::splitName($name);
$this->name = $name;
}
......@@ -392,9 +400,9 @@ class PersonsName {
function __toString() {
global $cfg;
$format = $cfg->getDefaultNameFormat();
list(,$func) = static::$formats[$format];
@list(,$func) = static::$formats[$this->format];
if (!$func) $func = 'getFull';
return call_user_func(array($this, $func));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment