Currently, Element::create expects to be passed a variable by reference. This makes it an extremely powerful method so that it can modify the original render array element in place while using the methods of the class.
If you create a new render array, you have to do the following:
$build = [
//...
];
$element = Element::create($build);
This can get extremely tedious and hard to read when you have a ton of $build variables just to provide a reference for this method. Nor do we want to remove the referencing functionality of Element::create. Instead, let's create a Element::createStandalone method that allows an element to be constructed without modifying the original element. This would be really nice so we can essentially create new Elements inline like so:
$element = Element::createStandalone([
//...
]);
Comments
Comment #3
markhalliwell