projects
/
m6w6
/
pq-gateway
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
first test
[m6w6/pq-gateway]
/
lib
/
pq
/
Mapper
/
Property
/
All.php
diff --git
a/lib/pq/Mapper/Property/All.php
b/lib/pq/Mapper/Property/All.php
index 0f45174a60bb8c2e3cfdbad82861c0dc2f6bf726..49fb0a622b4310a9ed410ee316362b62aeb6658c 100644
(file)
--- a/
lib/pq/Mapper/Property/All.php
+++ b/
lib/pq/Mapper/Property/All.php
@@
-11,12
+11,22
@@
use UnexpectedValueException;
class All implements RefPropertyInterface
{
use RefProperty;
class All implements RefPropertyInterface
{
use RefProperty;
-
+
+ /**
+ * Create a child rows mapping
+ * @param Mapper $mapper
+ * @param string $property
+ */
function __construct(Mapper $mapper, $property) {
$this->mapper = $mapper;
$this->property = $property;
}
function __construct(Mapper $mapper, $property) {
$this->mapper = $mapper;
$this->property = $property;
}
-
+
+ /**
+ * Read the child objects
+ * @param Row $row
+ * @param object $objectToUpdate
+ */
function read(Row $row, $objectToUpdate) {
$val = $this->extract($objectToUpdate);
if (!isset($val)) {
function read(Row $row, $objectToUpdate) {
$val = $this->extract($objectToUpdate);
if (!isset($val)) {
@@
-27,6
+37,12
@@
class All implements RefPropertyInterface
}
}
}
}
+ /**
+ * Write the child rows
+ * @param object $object
+ * @param Row $rowToUpdate
+ * @return callable deferred callback
+ */
function write($object, Row $rowToUpdate) {
$property = $this->findRefProperty($object);
$map = $this->mapper->mapOf($this->refClass);
function write($object, Row $rowToUpdate) {
$property = $this->findRefProperty($object);
$map = $this->mapper->mapOf($this->refClass);
@@
-41,6
+57,12
@@
class All implements RefPropertyInterface
};
}
};
}
+ /**
+ * Find the referring property that references $object on our foreign key
+ * @param object $object
+ * @return RefPropertyInterface[]
+ * @throws UnexpectedValueException
+ */
private function findRefProperty($object) {
$map = $this->mapper->mapOf($this->refClass);
$property = array_filter($map->getProperties(), function($property) use($object) {
private function findRefProperty($object) {
$map = $this->mapper->mapOf($this->refClass);
$property = array_filter($map->getProperties(), function($property) use($object) {
@@
-57,4
+79,4
@@
class All implements RefPropertyInterface
}
return current($property);
}
}
return current($property);
}
-}
\ No newline at end of file
+}