/** * {@inheritDoc} */ public function injectFile($obj, PropertyMapping $mapping) { $path = $this->storage->resolvePath($obj, $mapping->getFilePropertyName()); if ($path !== null) { $mapping->setFile($obj, new File($path, false)); } }
/** * Test that the configured mappings are accessed * correctly. */ public function testConfiguredMappingAccess() { $object = new DummyEntity(); $prop = new PropertyMapping('file', 'fileName'); $prop->setMapping(array('upload_destination' => '/tmp', 'delete_on_remove' => true, 'delete_on_update' => true, 'inject_on_load' => false)); $this->assertEquals('', $prop->getUploadDir($object)); $this->assertEquals('/tmp', $prop->getUploadDestination()); $this->assertEquals('file', $prop->getFilePropertyName()); $this->assertEquals('fileName', $prop->getFileNamePropertyName()); $this->assertTrue($prop->getDeleteOnRemove()); $this->assertTrue($prop->getDeleteOnUpdate()); $this->assertFalse($prop->getInjectOnLoad()); }