Commit c607ae1c by Jamie Carl

Completed the ElementCollection method forwarder

Any calls to methods on an ElementCollection that are not directly supported are now forwarded to ALL elements in the collection. So it is possible to update the content, change styles, etc on a bunch of elements at once.
parent e9cb34dd
Pipeline #1455 passed with stage
in 25 seconds
......@@ -178,6 +178,7 @@
<Compile Include="src\Html\Doctype.php" />
<Compile Include="src\Html\Dt.php" />
<Compile Include="src\Html\Element.php" />
<Compile Include="src\Html\ElementCollection.php" />
<Compile Include="src\Html\Em.php" />
<Compile Include="src\Html\Embed.php" />
<Compile Include="src\Html\Fieldset.php" />
......
......@@ -152,12 +152,9 @@ class Block extends Element implements \ArrayAccess, \Iterator {
*/
public function add() {
foreach(func_get_args() as $arg) {
foreach(func_get_args() as $arg)
$this->content[] = $arg;
}
return $this;
}
......
......@@ -135,8 +135,12 @@ class ElementCollection {
public function __call($method, $args){
if($element = current($this->elements))
return call_user_func_array(array($element, $method), $args);
if(is_array($this->elements)){
foreach($this->elements as $element)
call_user_func_array(array($element, $method), $args);
}
return $this;
......@@ -148,6 +152,7 @@ class ElementCollection {
foreach($this->elements as $element)
$output .= $element;
return $output;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment