Format.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 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 
15 
16 /**
17  * Format defines the interface for all format classes. Format instances
18  * are used to map external data representations like JSON, XML/SOAP or HTML
19  * to internal ones and vice versa. All data values are supposed to be scalar or
20  * array values except for wcmf::lib::model::Node instances, for which each external
21  * representation defines a special notation.
22  *
23  * @author ingo herwig <ingo@wemove.com>
24  */
25 interface Format {
26 
27  /**
28  * Get the MIME type of the format
29  * @param $response (optional)
30  * @return String
31  */
32  public function getMimeType(Response $response=null);
33 
34  /**
35  * Deserialize Request data from the external representation into Nodes and scalars/arrays.
36  * @param $request The Request instance
37  */
38  public function deserialize(Request $request);
39 
40  /**
41  * Serialize Response data according to the external representation.
42  * @param $response The Response instance
43  */
44  public function serialize(Response $response);
45 
46  /**
47  * Check if the response identified by it's cache id is cached for this format.
48  * @param $response The Response instance
49  * @return Boolean
50  */
51  public function isCached(Response $response);
52 
53  /**
54  * Get the caching date, if the response is cached.
55  * @param $response The Response instance
56  * @return DateTime or null, if not cached
57  */
58  public function getCacheDate(Response $response);
59 
60  /**
61  * Get the response headers.
62  * @param $response The Response instance
63  * @return Associative array with header names and values
64  */
65  public function getResponseHeaders(Response $response);
66 }
67 ?>
Response holds the response values that are used as output from Controller instances.
Definition: Response.php:20
Request holds the request values that are used as input to Controller instances.
Definition: Request.php:18
deserialize(Request $request)
Deserialize Request data from the external representation into Nodes and scalars/arrays.
getCacheDate(Response $response)
Get the caching date, if the response is cached.
Format defines the interface for all format classes.
Definition: Format.php:25
getMimeType(Response $response=null)
Get the MIME type of the format.
getResponseHeaders(Response $response)
Get the response headers.
serialize(Response $response)
Serialize Response data according to the external representation.
isCached(Response $response)
Check if the response identified by it's cache id is cached for this format.