示例#1
0
文件: Stream.php 项目: drakojn/io
 /**
  * @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;
 }
示例#2
0
文件: MapTest.php 项目: drakojn/io
 public function testGetRemoteName()
 {
     $name = 'user';
     $this->assertEquals($name, $this->object->getRemoteName());
     $this->assertInternalType('string', $this->object->getRemoteName());
 }