HtmlPage.php 3.01 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php

/**
 * @file
 * Contains \Drupal\Core\Page\HtmlPage.
 */

namespace Drupal\Core\Page;

use Drupal\Core\Template\Attribute;

/**
 * Data object for an HTML page.
 */
class HtmlPage extends HtmlFragment {

  /**
   * Attributes for the HTML element.
   *
   * @var \Drupal\Core\Template\Attribute
   */
  protected $htmlAttributes;

  /**
   * Attributes for the BODY element.
   *
   * @var \Drupal\Core\Template\Attribute
   */
  protected $bodyAttributes;

  /**
   * Auxiliary content area, above the main content.
   *
   * @var string
   */
  protected $bodyTop = '';

  /**
   * Auxiliary content area, below the main content.
   *
   * @var string
   */
  protected $bodyBottom = '';

  /**
   * The HTTP status code of this page.
   *
   * @var int
   */
  protected $statusCode = 200;

  /**
   * Constructs a new HtmlPage object.
   *
   * @param string $content
   *   (optional) The body content of the page.
57
58
   * @param array $cache_info
   *   The cache information.
59
60
61
   * @param string $title
   *   (optional) The title of the page.
   */
62
63
  public function __construct($content = '', array $cache_info = array(), $title = '') {
    parent::__construct($content, $cache_info);
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162

    $this->title = $title;

    $this->htmlAttributes = new Attribute();
    $this->bodyAttributes = new Attribute();
  }

  /**
   * Returns the HTML attributes for this HTML page.
   *
   * @return \Drupal\Core\Template\Attribute
   */
  public function getHtmlAttributes() {
    return $this->htmlAttributes;
  }

  /**
   * Returns the HTML attributes for the body element of this page.
   *
   * @return \Drupal\Core\Template\Attribute
   */
  public function getBodyAttributes() {
    return $this->bodyAttributes;
  }

  /**
   * Sets the top-content of this page.
   *
   * @param string $content
   *   The top-content to set.
   *
   * @return self
   *   The called object.
   */
  public function setBodyTop($content) {
    $this->bodyTop = $content;
    return $this;
  }

  /**
   * Returns the top-content of this page.
   *
   * @return string
   *   The top-content of this page.
   */
  public function getBodyTop() {
    return $this->bodyTop;
  }

  /**
   * Sets the bottom-content of this page.
   *
   * @param string $content
   *   The bottom-content to set.
   *
   * @return self
   *   The called object.
   */
  public function setBodyBottom($content) {
    $this->bodyBottom = $content;
    return $this;
  }

  /**
   * Returns the bottom-content of this page.
   *
   * @return string
   *   The bottom-content of this page.
   */
  public function getBodyBottom() {
    return $this->bodyBottom;
  }

  /**
   * Sets the HTTP status of this page.
   *
   * @param int $status
   *   The status code to set.
   *
   * @return self
   *   The called object.
   */
  public function setStatusCode($status) {
    $this->statusCode = $status;
    return $this;
  }

  /**
   * Returns the status code of this response.
   *
   * @return int
   *   The status code of this page.
   */
  public function getStatusCode() {
    return $this->statusCode;
  }

}