DefaultResponse.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2015 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
12 
16 
17 /**
18  * Default Response implementation.
19  *
20  * @author ingo herwig <ingo@wemove.com>
21  */
23 
24  private $_cacheId = null;
25  private $_status = self::STATUS_200;
26  private $_file = null;
27  private $_isFinal = false;
28 
29  /**
30  * Constructor
31  * @param $formatter
32  */
33  public function __construct(Formatter $formatter) {
34  parent::__construct($formatter);
35  }
36 
37  /**
38  * @see Response::setCacheId()
39  */
40  public function setCacheId($cacheId) {
41  $this->_cacheId = $cacheId;
42  }
43 
44  /**
45  * @see Response::getCacheId()
46  */
47  public function getCacheId() {
48  return $this->_cacheId;
49  }
50 
51  /**
52  * @see Response::setStatus()
53  */
54  public function setStatus($status) {
55  $this->_status = $status;
56  }
57 
58  /**
59  * @see Response::getStatus()
60  */
61  public function getStatus() {
62  return $this->_status;
63  }
64 
65  /**
66  * @see Response::setFile()
67  */
68  public function setFile($filename, $content='') {
69  if (strlen($content) == 0 && file_exists($filename)) {
70  $content = file_get_contents($filename);
71  }
72  $this->_file = array(
73  'filename' => $filename,
74  'content' => $content
75  );
76  $this->setFinal();
77  }
78 
79  /**
80  * @see Response::getFile()
81  */
82  public function getFile() {
83  return $this->_file;
84  }
85 
86  /**
87  * @see Response::setFinal()
88  */
89  public function setFinal() {
90  $this->_isFinal = true;
91  }
92 
93  /**
94  * @see Response::isFinal()
95  */
96  public function isFinal() {
97  return $this->_isFinal;
98  }
99 }
100 ?>
Response holds the response values that are used as output from Controller instances.
Definition: Response.php:20
Default Response implementation.
__construct(Formatter $formatter)
Constructor.
Formatter is the single entry point for request/response formatting.
Definition: Formatter.php:23
AbstractControllerMessage is the base class for request/response implementations. ...