Adds MacroableTrait to FormBuilder and HtmlBuilder

This commit is contained in:
Nicholas Ruunu committed 2014-02-27 11:45:39 +01:00
1 parent 50d7f44895
commit c0f9116999
2 files changed
+6 -76

No files matched your search

+3 -38
View File
@@ -1,9 +1,12 @@
<?php namespace Illuminate\Html;
use Illuminate\Routing\UrlGenerator;
use Illuminate\Support\Traits\MacroableTrait;
class HtmlBuilder {
use MacroableTrait;
/**
* The URL generator instance.
*
@@ -11,13 +14,6 @@ class HtmlBuilder {
*/
protected $url;
/**
* The registered html macros.
*
* @var array
*/
protected $macros;
/**
* Create a new HTML builder instance.
*
@@ -29,18 +25,6 @@ class HtmlBuilder {
$this->url = $url;
}
/**
* Register a custom HTML macro.
*
* @param string $name
* @param callable $macro
* @return void
*/
public function macro($name, $macro)
{
$this->macros[$name] = $macro;
}
/**
* Convert an HTML string to entities.
*
@@ -389,23 +373,4 @@ class HtmlBuilder {
return $safe;
}
/**
* Dynamically handle calls to the html class.
*
* @param string $method
* @param array $parameters
* @return mixed
*
* @throws \BadMethodCallException
*/
public function __call($method, $parameters)
{
if (isset($this->macros[$method]))
{
return call_user_func_array($this->macros[$method], $parameters);
}
throw new \BadMethodCallException("Method {$method} does not exist.");
}
}