TYPO3  7.6
DateHeader.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of SwiftMailer.
5  * (c) 2004-2009 Chris Corbyn
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10 
17 {
23  private $_timestamp;
24 
38  public function __construct($name, Swift_Mime_Grammar $grammar)
39  {
40  $this->setFieldName($name);
41  parent::__construct($grammar);
42  }
43 
52  public function getFieldType()
53  {
54  return self::TYPE_DATE;
55  }
56 
64  public function setFieldBodyModel($model)
65  {
66  $this->setTimestamp($model);
67  }
68 
76  public function getFieldBodyModel()
77  {
78  return $this->getTimestamp();
79  }
80 
86  public function getTimestamp()
87  {
88  return $this->_timestamp;
89  }
90 
96  public function setTimestamp($timestamp)
97  {
98  if (!is_null($timestamp)) {
99  $timestamp = (int) $timestamp;
100  }
101  $this->clearCachedValueIf($this->_timestamp != $timestamp);
102  $this->_timestamp = $timestamp;
103  }
104 
115  public function getFieldBody()
116  {
117  if (!$this->getCachedValue()) {
118  if (isset($this->_timestamp)) {
119  $this->setCachedValue(date('r', $this->_timestamp));
120  }
121  }
122 
123  return $this->getCachedValue();
124  }
125 }