/** * Evaluate this node and return the correct object. * * Handles each part (denoted by .) in $this->objectPath in the following order: * - call appropriate getter * - call public property, if exists * - fail * * The first part of the object path has to be a variable in the * VariableProvider. * * @param RenderingContextInterface $renderingContext * @return object The evaluated object, can be any object type. */ public function evaluate(RenderingContextInterface $renderingContext) { $variableProvider = $renderingContext->getVariableProvider(); switch (strtolower($this->objectPath)) { case '_all': return $variableProvider->getAll(); case 'true': case 'on': case 'yes': return TRUE; case 'false': case 'off': case 'no': return FALSE; default: return VariableExtractor::extract($variableProvider, $this->objectPath, $this->accessors); } }
/** * @param mixed $subject * @param string $path * @param string $accessor * @param mixed $expected * @test * @dataProvider getExtractRedectAccessorTestValues */ public function testExtractRedetectsAccessorIfUnusableAccessorPassed($subject, $path, $accessor, $expected) { $result = VariableExtractor::extract($subject, 'test', array($accessor)); $this->assertEquals($expected, $result); }