First fake subscriber model to show namespacing and autoloading.
This commit is contained in:
@@ -165,6 +165,7 @@ class Initializer {
|
||||
|
||||
public function admin_page() {
|
||||
// set data
|
||||
$subscriber = new \MailPoet\Models\Subscriber();
|
||||
$this->data = array(
|
||||
'title' => __('Twig Sample page'),
|
||||
'text' => 'Lorem ipsum dolor sit amet',
|
||||
@@ -172,7 +173,8 @@ class Initializer {
|
||||
'users' => array(
|
||||
array('name' => 'Joo', 'email' => 'jonathan@mailpoet.com'),
|
||||
array('name' => 'Marco', 'email' => 'marco@mailpoet.com'),
|
||||
)
|
||||
),
|
||||
'subscriber' => $subscriber->name
|
||||
);
|
||||
// Sample page using Twig
|
||||
echo $this->renderer->render('index.html', $this->data);
|
||||
|
11
lib/models/subscriber.php
Normal file
11
lib/models/subscriber.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php namespace MailPoet\Models;
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class Subscriber {
|
||||
|
||||
public $name;
|
||||
|
||||
public function __construct () {
|
||||
$this->name = 'First Subscriber';
|
||||
}
|
||||
}
|
@@ -25,6 +25,9 @@
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h3>Autoloaded Subscriber</h3>
|
||||
<p>{{ subscriber }}</p>
|
||||
|
||||
<!-- Notice -->
|
||||
<h3>Notices</h3>
|
||||
<p><a href="javascript:;" onclick="MailPoet.Notice.success('Test');">Trigger success</a></p>
|
||||
|
Reference in New Issue
Block a user