Example #1
0
 /**
  * @param Mapper\Map $map
  * @param            $data
  *
  * @return bool
  */
 protected function write(Mapper\Map $map, $data)
 {
     $reflectionProperty = new \ReflectionProperty($map->getLocalName(), $map->getIdentifier());
     $reflectionProperty->setAccessible(true);
     $identifier = $reflectionProperty->getValue($data);
     $new = false;
     if (!$identifier) {
         $identifier = spl_object_hash($data);
         $new = true;
     }
     $uri = $this->buildUri($map->getRemoteName()) . '/' . $identifier;
     $result = (bool) file_put_contents($uri, $this->descriptor->serialize($map, $data), false, $this->context ?: null);
     if ($result && $new) {
         $reflectionProperty->setValue($data, $identifier);
     }
     return $result;
 }
Example #2
0
 public function testGetRemoteName()
 {
     $name = 'user';
     $this->assertEquals($name, $this->object->getRemoteName());
     $this->assertInternalType('string', $this->object->getRemoteName());
 }