Symfony\Component\Form\PropertyPath::getValue PHP Method

getValue() public method

Example: $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 getValue ( object | array $objectOrArray ) : mixed
$objectOrArray object | array The object or array to traverse
return mixed The value at the end of the property path
    public function getValue($objectOrArray)
    {
        return $this->readPropertyPath($objectOrArray, 0);
    }

Usage Example

Esempio n. 1
0
 public function testGetValueThrowsExceptionIfPropertyDoesNotExist()
 {
     $path = new PropertyPath('foobar');
     $this->setExpectedException('Symfony\\Component\\Form\\Exception\\InvalidPropertyException');
     $path->getValue(new Author());
 }
All Usage Examples Of Symfony\Component\Form\PropertyPath::getValue