예제 #1
0
 /**
  * Reverse the property links of a map.
  *
  * @param object|array $from
  * @param object|array $to
  * @param MapInterface $map
  *
  * @return self
  */
 public function reverse(&$from, $to, MapInterface $map)
 {
     $mapper = new Mapper();
     foreach ($map->getEmbeds() as $embed) {
         // Get embedded value from $to
         $originalEmbedded = $this->propertyAccess->getValue($to, $embed->getTo());
         // Process the embedded
         (new Mapper($this->propertyAccess))->reverse($from, $originalEmbedded, $embed->getMap());
     }
     return $this;
 }
예제 #2
0
 /**
  * Reverse the property links of a map.
  *
  * @param object|array $from
  * @param object|array $to
  * @param MapInterface $map
  *
  * @return self
  */
 public function reverse(&$from, $to, MapInterface $map)
 {
     foreach ($map->getLinks() as $link) {
         if ($link->hasTransformer()) {
             $value = $link->getTransformer()->reverse($this->propertyAccess->getValue($to, $link->getTo()), $to);
         } else {
             $value = $this->propertyAccess->getValue($to, $link->getTo());
         }
         $this->propertyAccess->setValue($from, $link->getFrom(), $value);
     }
     return $this;
 }
 /**
  * Reverse the property links of a map.
  *
  * @param object|array $from
  * @param object|array $to
  * @param MapInterface $map
  *
  * @return self
  */
 public function reverse(&$from, $to, MapInterface $map)
 {
     $mapper = new Mapper($this->propertyAccess);
     foreach ($map->getEmbeddedCollections() as $collection) {
         // New value
         $value = [];
         // Source items
         $source = $this->propertyAccess->getValue($to, $collection->getTo());
         foreach ($source as $item) {
             $newItem = $collection->getFactory()->reverse($item);
             $value[] = $mapper->reverse($newItem, $item, $collection->getMap());
         }
         $this->propertyAccess->setValue($from, $collection->getFrom(), $value);
     }
     return $this;
 }