/** * {@inheritdoc} */ public function execute(MetaModel $metaModel) { $array = $this->subNode->execute($metaModel); if (!is_array($array) && !$array instanceof \ArrayAccess) { throw new ExecutionException("Array access is impossible on a variable that is not an array, or implementing \\ArrayAccess"); } if (!isset($array[$this->key])) { return null; } return $array[$this->key]; }
/** * {@inheritdoc} */ public function execute(MetaModel $metaModel) { $object = $this->subNode->execute($metaModel); if (is_null($object)) { throw new ExecutionException("Calling method '{$this->method}' on null"); } $reflectionMethod = new \ReflectionMethod($object, $this->method); // God mode if ($reflectionMethod->isPrivate() || $reflectionMethod->isProtected()) { $reflectionMethod->setAccessible(true); } return $reflectionMethod->invoke($object); }
/** * {@inheritdoc} */ public function execute(MetaModel $metaModel) { $object = $this->subNode->execute($metaModel); $propertyAccessor = \Symfony\Component\PropertyAccess\PropertyAccess::createPropertyAccessor(); return $propertyAccessor->getValue($object, $this->property); }