Allow for passing variables to views with more expressive method calls.
Example: with_foo($bar) instead of with('foo', $bar) Signed-off-by: Franz Liedke <franz@develophp.org>
This commit is contained in:
parent
4d7d67dd82
commit
5e2373817d
|
@ -551,4 +551,20 @@ public function __toString()
|
|||
return $this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Magic Method for handling dynamic functions.
|
||||
*
|
||||
* This method handles calls to dynamic with helpers.
|
||||
*/
|
||||
public function __call($method, $parameters)
|
||||
{
|
||||
if (strpos($method, 'with_') === 0)
|
||||
{
|
||||
$key = substr($method, 5);
|
||||
return $this->with($key, $parameters[0]);
|
||||
}
|
||||
|
||||
throw new \Exception("Method [$method] is not defined on the View class.");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue