Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
3f0adcb5
Commit
3f0adcb5
authored
May 25, 2012
by
Dayle Rees
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow global messages format
Signed-off-by: Dayle Rees <thepunkfan@gmail.com>
parent
34919aff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
laravel/messages.php
+28
-3
No files found.
laravel/messages.php
View file @
3f0adcb5
...
...
@@ -10,6 +10,13 @@ class Messages {
public
$messages
;
/**
* Default format for message output.
*
* @var string
*/
public
$format
=
':message'
;
/**
* Create a new Messages instance.
*
* @param array $messages
...
...
@@ -69,6 +76,21 @@ class Messages {
}
/**
* Set the default message format for output.
*
* <code>
* // Apply a new default format.
* $messages->set_format('email', '<p>this is my :message</p>');
* </code>
*
* @param string $format
*/
public
function
set_format
(
$format
=
':message'
)
{
$this
->
format
=
$format
;
}
/**
* Get the first message from the container for a given key.
*
* <code>
...
...
@@ -86,8 +108,9 @@ class Messages {
* @param string $format
* @return string
*/
public
function
first
(
$key
=
null
,
$format
=
':message'
)
public
function
first
(
$key
=
null
,
$format
=
null
)
{
$format
=
(
$format
===
null
)
?
$this
->
format
:
$format
;
$messages
=
is_null
(
$key
)
?
$this
->
all
(
$format
)
:
$this
->
get
(
$key
,
$format
);
return
(
count
(
$messages
)
>
0
)
?
$messages
[
0
]
:
''
;
...
...
@@ -108,8 +131,9 @@ class Messages {
* @param string $format
* @return array
*/
public
function
get
(
$key
,
$format
=
':message'
)
public
function
get
(
$key
,
$format
=
null
)
{
$format
=
(
$format
===
null
)
?
$this
->
format
:
$format
;
if
(
array_key_exists
(
$key
,
$this
->
messages
))
{
return
$this
->
format
(
$this
->
messages
[
$key
],
$format
);
...
...
@@ -132,8 +156,9 @@ class Messages {
* @param string $format
* @return array
*/
public
function
all
(
$format
=
':message'
)
public
function
all
(
$format
=
null
)
{
$format
=
(
$format
===
null
)
?
$this
->
format
:
$format
;
$all
=
array
();
foreach
(
$this
->
messages
as
$messages
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment