Completed
Pull Request — master (#2)
by Beñat
02:34
created

Form::display()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace LIN3S\WPSymfonyForm\Admin\Views;
4
5
use LIN3S\WPSymfonyForm\Admin\Views\Components\LogsTable;
6
7
/**
8
 * Single form page.
9
 *
10
 * @author Beñat Espiña <[email protected]>
11
 */
12
class Form implements Page
13
{
14
    /**
15
     * The logs table component.
16
     *
17
     * @var LogsTable
18
     */
19
    private $logsTable;
20
21
    /**
22
     * The form type name.
23
     *
24
     * @var string
25
     */
26
    private $formType;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param string    $formType  The form type name
32
     * @param LogsTable $logsTable The logs table component
33
     */
34
    public function __construct($formType, LogsTable $logsTable)
35
    {
36
        $this->formType = $formType;
37
        $this->logsTable = $logsTable;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function display()
44
    {
45
        $this->logsTable->prepare_items();
46
47
        ?>
48
        <div class="wrap">
49
            <h2>
50
                <?php _e('Sent emails logs of ', \WPSymfonyForm::TRANSLATION_DOMAIN); ?>
51
52
                <?php echo '"' . $this->formType . '"' ?>
53
            </h2>
54
            <div id="poststuff">
55
                <div id="post-body" class="metabox-holder">
56
                    <div id="post-body-content">
57
                        <?php $this->logsTable->display() ?>
58
                    </div>
59
                </div>
60
                <br class="clear">
61
            </div>
62
        </div>
63
        <?php
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function screenOptions()
70
    {
71
        add_screen_option('per_page', [
72
            'label'   => 'Logs',
73
            'default' => 10,
74
            'option'  => 'logs_per_page',
75
        ]);
76
    }
77
}
78