8c950568f365d82fb32b6af8ef5bdf3505dede82
[m6w6/pq-gateway] / lib / pq / Mapper / MapInterface.php
1 <?php
2
3 namespace pq\Mapper;
4
5 use pq\Gateway\Row;
6 use pq\Gateway\Rowset;
7 use pq\Gateway\Table;
8
9 interface MapInterface
10 {
11 /**
12 * Get the mapped class' name
13 * @return string
14 */
15 function getClass();
16
17 /**
18 * The the underlying table gateway
19 * @return Table
20 */
21 function getGateway();
22
23 /**
24 * Get the mapped properties
25 * @return PropertyInterface[]
26 */
27 function getProperties();
28
29 /**
30 * Add a property to map
31 * @param PropertyInterface $property
32 */
33 function addProperty(PropertyInterface $property);
34
35 /**
36 * Get all child rows by foreign key
37 * @param Row $row
38 * @param string $refName
39 * @param array $objects
40 * @return Rowset
41 */
42 function allOf(Row $row, $refName, &$objects = null);
43
44 /**
45 * Get the parent row by foreign key
46 * @param Row $row
47 * @param string $refName
48 * @param array $objects
49 * @return Rowset
50 */
51 function refOf(Row $row, $refName, &$objects = null);
52
53 /**
54 * Get the table relation reference
55 * @param MapInterface $map origin
56 * @param string $refName relations reference name
57 * @return Table\Reference
58 */
59 function relOf(MapInterface $map, $refName);
60
61 /**
62 * Map a row to an object
63 * @param Row $row
64 * @return object
65 */
66 function map(Row $row);
67
68 /**
69 * Map a rowset to an array of objects
70 * @param Rowset $rows
71 * @return object[]
72 */
73 function mapAll(Rowset $rows);
74
75 /**
76 * Unmap on object
77 * @param object $object
78 * @return Row
79 */
80 function unmap($object);
81 }