diff --git a/core/lib/Drupal/Core/Render/ReadOnlyRenderArray.php b/core/lib/Drupal/Core/Render/ReadOnlyRenderArray.php index ac03a32..b17a680 100644 --- a/core/lib/Drupal/Core/Render/ReadOnlyRenderArray.php +++ b/core/lib/Drupal/Core/Render/ReadOnlyRenderArray.php @@ -10,6 +10,16 @@ class ReadOnlyRenderArray extends \ArrayObject implements RenderableInterface { /** + * ReadOnlyRenderArray constructor. + * + * @param array $input + * The render array to wrap into a read-only object. + */ + public function __construct(array $input = []) { + parent::__construct($input, 0, RenderArrayIterator::class); + } + + /** * {@inheritdoc} */ public function toRenderable() { @@ -17,6 +27,18 @@ public function toRenderable() { } /** + * Magic getter since Twig sometimes tries to access properties. + * + * @param mixed $index + * The index with the value. + * + * @return \Drupal\Core\Render\ReadOnlyRenderArray|mixed + */ + public function __get($index) { + return $this->offsetGet($index); + } + + /** * {@inheritdoc} */ public function offsetGet($index) {