...
|
...
|
@@ -33,7 +33,18 @@ class Messages |
|
|
*/
|
|
|
public function customMessages(array $customMessages = array())
|
|
|
{
|
|
|
$this->_customMessages = $customMessages;
|
|
|
$_customMessages = array();
|
|
|
foreach ($customMessages as $key => $custom) {
|
|
|
if (is_string($custom)) {
|
|
|
$_customMessages[$key] = $custom;
|
|
|
} elseif (is_array($custom)) {
|
|
|
foreach ($custom as $_key => $_val) {
|
|
|
$_customMessages[$key . '.' . $_key] = $_val;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
unset($customMessages);
|
|
|
$this->_customMessages = $_customMessages;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -117,15 +128,17 @@ class Messages |
|
|
* @param null $type
|
|
|
* @return string
|
|
|
*/
|
|
|
public function getMessages($key, $type = null)
|
|
|
public function getMessages($attribute, $rule, $type = null)
|
|
|
{
|
|
|
if (isset($this->_customMessages[$key])) {
|
|
|
return $this->_customMessages[$key];
|
|
|
} elseif (array_key_exists($key, $this->defaultMessagesLanguage)) {
|
|
|
if (isset($this->defaultMessagesLanguage[$key][$type])) {
|
|
|
return $this->defaultMessagesLanguage[$key][$type];
|
|
|
if (isset($this->_customMessages[$attribute . '.' . $rule])) {
|
|
|
return $this->_customMessages[$attribute . '.' . $rule];
|
|
|
} elseif (isset($this->_customMessages[$attribute])) {
|
|
|
return $this->_customMessages[$attribute];
|
|
|
} elseif (array_key_exists($rule, $this->defaultMessagesLanguage)) {
|
|
|
if (isset($this->defaultMessagesLanguage[$rule][$type])) {
|
|
|
return $this->defaultMessagesLanguage[$rule][$type];
|
|
|
}
|
|
|
return $this->defaultMessagesLanguage[$key];
|
|
|
return $this->defaultMessagesLanguage[$rule];
|
|
|
}
|
|
|
return '';
|
|
|
}
|
...
|
...
|
|