X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fpq%2FMapper%2FProperty%2FAll.php;h=49fb0a622b4310a9ed410ee316362b62aeb6658c;hb=9667b439ab6355373207938e9a6fb20c68857786;hp=0f45174a60bb8c2e3cfdbad82861c0dc2f6bf726;hpb=d4d84fb9b85f0216bd611946d59054a606c71960;p=m6w6%2Fpq-gateway diff --git a/lib/pq/Mapper/Property/All.php b/lib/pq/Mapper/Property/All.php index 0f45174..49fb0a6 100644 --- 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; - + + /** + * Create a child rows mapping + * @param Mapper $mapper + * @param string $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)) { @@ -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); @@ -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) { @@ -57,4 +79,4 @@ class All implements RefPropertyInterface } return current($property); } -} \ No newline at end of file +}