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 *
RevLine 
[6351]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');
[6437]9/*
[6559]10  Valores padrão
[6351]11
[6559]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
[6351]22class Collection {
23
[6437]24    public $itens;
[6351]25    public $href;
26    public $error;
27    public $pagination;
[6437]28    public $queries;
[6351]29    public $template;
30    public $type;
[6437]31    public $data;
[6523]32    public $links;
[6351]33
[6523]34    function __construct($config, $className, $id = null) {
[6351]35        foreach ($config as $key => $value) {
36            if ($value['class'] == $className) {
[6559]37                $uri = ($id ? (preg_replace('/\/[:][a-zA-Z-0-9]+/', '', $key) . '/' . $id ) : $key);
[6351]38                break;
39            }
40        }
41        $this->href = $uri;
42    }
43
[6559]44    function addLink($link) {
[6437]45        $this->links[] = $link;
46    }
[6559]47
[6351]48    function addItem($item) {
49        $this->itens[] = $item;
50    }
[6559]51
52    function addData($data) {
[6429]53        $this->data[] = $data;
[6351]54    }
55
56    function getData() {
57        return $this->data;
58    }
[6559]59
[6351]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
[6429]76    function addQueries($queries) {
77        $this->queries[] = $queries;
[6351]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.