1 | <?php |
||
9 | class HasManyList extends RelationList { |
||
10 | |||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $foreignKey; |
||
15 | |||
16 | /** |
||
17 | * Create a new HasManyList object. |
||
18 | * Generation of the appropriate record set is left up to the caller, using the normal |
||
19 | * {@link DataList} methods. Addition arguments are used to support {@@link add()} |
||
20 | * and {@link remove()} methods. |
||
21 | * |
||
22 | * @param string $dataClass The class of the DataObjects that this will list. |
||
23 | * @param string $foreignKey The name of the foreign key field to set the ID filter against. |
||
24 | */ |
||
25 | public function __construct($dataClass, $foreignKey) { |
||
30 | |||
31 | /** |
||
32 | * Gets the field name which holds the related object ID. |
||
33 | * |
||
34 | * @return string |
||
35 | */ |
||
36 | public function getForeignKey() { |
||
39 | |||
40 | /** |
||
41 | * @param null|int $id |
||
42 | * @return array |
||
43 | */ |
||
44 | protected function foreignIDFilter($id = null) { |
||
61 | |||
62 | /** |
||
63 | * Adds the item to this relation. |
||
64 | * |
||
65 | * It does so by setting the relationFilters. |
||
66 | * |
||
67 | * @param DataObject|int $item The DataObject to be added, or its ID |
||
68 | */ |
||
69 | public function add($item) { |
||
93 | |||
94 | /** |
||
95 | * Remove an item from this relation. |
||
96 | * |
||
97 | * Doesn't actually remove the item, it just clears the foreign key value. |
||
98 | * |
||
99 | * @param int $itemID The ID of the item to be removed. |
||
100 | */ |
||
101 | public function removeByID($itemID) { |
||
106 | |||
107 | /** |
||
108 | * Remove an item from this relation. |
||
109 | * Doesn't actually remove the item, it just clears the foreign key value. |
||
110 | * |
||
111 | * @param DataObject $item The DataObject to be removed |
||
112 | * @todo Maybe we should delete the object instead? |
||
113 | */ |
||
114 | public function remove($item) { |
||
133 | } |
||
134 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: