$path = new PropertyPath('child.name');
echo $path->getValue($object);
equals echo $object->getChild()->getName();
This method first tries to find a public getter for each property in the
path. The name of the getter must be the camel-cased property name
prefixed with "get" or "is".
If the getter does not exist, this method tries to find a public
property. The value of the property is then returned.
If neither is found, an exception is thrown. public function getValue($objectOrArray)
{
return $this->readPropertyPath($objectOrArray, 0);
}
public function testGetValueThrowsExceptionIfPropertyDoesNotExist() { $path = new PropertyPath('foobar'); $this->setExpectedException('Symfony\\Component\\Form\\Exception\\InvalidPropertyException'); $path->getValue(new Author()); }