Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
3 deletions
+28
-3
messages.php
laravel/messages.php
+28
-3
No files found.
laravel/messages.php
View file @
3f0adcb5
...
@@ -9,6 +9,13 @@ class Messages {
...
@@ -9,6 +9,13 @@ class Messages {
*/
*/
public
$messages
;
public
$messages
;
/**
* Default format for message output.
*
* @var string
*/
public
$format
=
':message'
;
/**
/**
* Create a new Messages instance.
* Create a new Messages instance.
*
*
...
@@ -68,6 +75,21 @@ class Messages {
...
@@ -68,6 +75,21 @@ class Messages {
return
$this
->
first
(
$key
)
!==
''
;
return
$this
->
first
(
$key
)
!==
''
;
}
}
/**
* 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.
* Get the first message from the container for a given key.
*
*
...
@@ -86,8 +108,9 @@ class Messages {
...
@@ -86,8 +108,9 @@ class Messages {
* @param string $format
* @param string $format
* @return string
* @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
);
$messages
=
is_null
(
$key
)
?
$this
->
all
(
$format
)
:
$this
->
get
(
$key
,
$format
);
return
(
count
(
$messages
)
>
0
)
?
$messages
[
0
]
:
''
;
return
(
count
(
$messages
)
>
0
)
?
$messages
[
0
]
:
''
;
...
@@ -108,8 +131,9 @@ class Messages {
...
@@ -108,8 +131,9 @@ class Messages {
* @param string $format
* @param string $format
* @return array
* @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
))
if
(
array_key_exists
(
$key
,
$this
->
messages
))
{
{
return
$this
->
format
(
$this
->
messages
[
$key
],
$format
);
return
$this
->
format
(
$this
->
messages
[
$key
],
$format
);
...
@@ -132,8 +156,9 @@ class Messages {
...
@@ -132,8 +156,9 @@ class Messages {
* @param string $format
* @param string $format
* @return array
* @return array
*/
*/
public
function
all
(
$format
=
':message'
)
public
function
all
(
$format
=
null
)
{
{
$format
=
(
$format
===
null
)
?
$this
->
format
:
$format
;
$all
=
array
();
$all
=
array
();
foreach
(
$this
->
messages
as
$messages
)
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