Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 79d5e21

Browse files
committed
Merge pull request laravel#8349 from lucasmichot/5.0-messagebag
[5.0] MessageBag : variables set only if and when necessary
2 parents f5dd6fb + bba7f46 commit 79d5e21

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/Illuminate/Support/MessageBag.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,12 @@ public function first($key = null, $format = null)
130130
*/
131131
public function get($key, $format = null)
132132
{
133-
$format = $this->checkFormat($format);
134-
135133
// If the message exists in the container, we will transform it and return
136134
// the message. Otherwise, we'll return an empty array since the entire
137135
// methods is to return back an array of messages in the first place.
138136
if (array_key_exists($key, $this->messages))
139137
{
140-
return $this->transform($this->messages[$key], $format, $key);
138+
return $this->transform($this->messages[$key], $this->checkFormat($format), $key);
141139
}
142140

143141
return array();
@@ -178,10 +176,10 @@ protected function transform($messages, $format, $messageKey)
178176
// We will simply spin through the given messages and transform each one
179177
// replacing the :message place holder with the real message allowing
180178
// the messages to be easily formatted to each developer's desires.
179+
$replace = array(':message', ':key');
180+
181181
foreach ($messages as &$message)
182182
{
183-
$replace = array(':message', ':key');
184-
185183
$message = str_replace($replace, array($message, $messageKey), $format);
186184
}
187185

0 commit comments

Comments
 (0)