source: trunk/prototype/rest/hypermedia/collection.php @ 6559

Revision 6559, 1.9 KB checked in by acoutinho, 12 years ago (diff)

Ticket #2766 - Criacao de recurso unico para contatos dos usuario

  • Property svn:executable set to *
Line 
1<?php
2
3include_once('item.php');
4include_once('link.php');
5include_once('data.php');
6include_once('template.php');
7include_once('query.php');
8include_once('error.php');
9/*
10  Valores padrão
11
12  Números são enviados como números, sem aspas;
13  Atributos não obrigatórios sem valor serão nulos;
14  Strings vazias serão nulos;
15  Todos os indices / chaves estarão sempre presentes na mensagem;
16  Arrays vazios serão nulos;
17  Objetos vazios serão nulos;
18  Números sem valor serão nulos;
19  valores booleanos são escritos como booleanos (sem aspas);
20 */
21
22class Collection {
23
24    public $itens;
25    public $href;
26    public $error;
27    public $pagination;
28    public $queries;
29    public $template;
30    public $type;
31    public $data;
32    public $links;
33
34    function __construct($config, $className, $id = null) {
35        foreach ($config as $key => $value) {
36            if ($value['class'] == $className) {
37                $uri = ($id ? (preg_replace('/\/[:][a-zA-Z-0-9]+/', '', $key) . '/' . $id ) : $key);
38                break;
39            }
40        }
41        $this->href = $uri;
42    }
43
44    function addLink($link) {
45        $this->links[] = $link;
46    }
47
48    function addItem($item) {
49        $this->itens[] = $item;
50    }
51
52    function addData($data) {
53        $this->data[] = $data;
54    }
55
56    function getData() {
57        return $this->data;
58    }
59
60    function setTemplate($template) {
61        $this->template = $template;
62    }
63
64    function getTemplate() {
65        return $this->template;
66    }
67
68    function setType($type) {
69        $this->type = $type;
70    }
71
72    function getType() {
73        return $this->type;
74    }
75
76    function addQueries($queries) {
77        $this->queries[] = $queries;
78    }
79
80    function getQueries() {
81        return $this->queries;
82    }
83
84    function setError($error) {
85        $this->error = $error;
86    }
87
88    function getError() {
89        return $this->error;
90    }
91
92    function setPagination($pagination) {
93        $this->pagination = $pagination;
94    }
95
96    function getPagination() {
97        return $this->pagination;
98    }
99
100}
101
102?>
Note: See TracBrowser for help on using the repository browser.