importMessages() public static method

Import an array of messages. Only known messages are imported.
public static importMessages ( array $messages, string $locale = null ) : void
$messages array
$locale string
return void
Ejemplo n.º 1
0
 public function testImportMessages()
 {
     Message::importMessages(['Hello World!', 'Hello Piñata!']);
     $this->assertNotNull(Message::whereCode('hello.world')->first());
     $this->assertNotNull(Message::whereCode('hello.piñata')->first());
     Message::truncate();
 }
Ejemplo n.º 2
0
 public function testImportMessagesCopiesFromDeprecated()
 {
     $this->seedDeprecatedData();
     Message::importMessages(['Hello World!', 'Hello Piñata!']);
     $newMessage = Message::whereCode('hello.piñata')->first();
     $deprecatedMessage = Message::whereCode('hello.pinata')->first();
     $this->assertNotNull($newMessage);
     $this->assertEquals($newMessage->messageData, $deprecatedMessage->messageData);
     Message::truncate();
 }
Ejemplo n.º 3
0
 /**
  * Scans the theme templates for message references.
  * @return void
  */
 public function scanForMessages()
 {
     $messages = [];
     foreach (Layout::all() as $layout) {
         $messages = array_merge($messages, $this->parseContent($layout->markup));
     }
     foreach (Page::all() as $page) {
         $messages = array_merge($messages, $this->parseContent($page->markup));
     }
     foreach (Partial::all() as $partial) {
         $messages = array_merge($messages, $this->parseContent($partial->markup));
     }
     Message::importMessages($messages);
 }