Adds MacroableTrait to FormBuilder and HtmlBuilder
This commit is contained in:
1 parent
50d7f44895
commit
c0f9116999
2 files changed
+6
-76
No files matched your search
+3
-38
@@ -2,9 +2,12 @@
|
||||
|
||||
use Illuminate\Routing\UrlGenerator;
|
||||
use Illuminate\Session\Store as Session;
|
||||
use Illuminate\Support\Traits\MacroableTrait;
|
||||
|
||||
class FormBuilder {
|
||||
|
||||
use MacroableTrait;
|
||||
|
||||
/**
|
||||
* The HTML builder instance.
|
||||
*
|
||||
@@ -47,13 +50,6 @@ class FormBuilder {
|
||||
*/
|
||||
protected $labels = array();
|
||||
|
||||
/**
|
||||
* The registered form builder macros.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $macros = array();
|
||||
|
||||
/**
|
||||
* The reserved form open attributes.
|
||||
*
|
||||
@@ -730,18 +726,6 @@ class FormBuilder {
|
||||
return '<button'.$this->html->attributes($options).'>'.$value.'</button>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a custom form macro.
|
||||
*
|
||||
* @param string $name
|
||||
* @param callable $macro
|
||||
* @return void
|
||||
*/
|
||||
public function macro($name, $macro)
|
||||
{
|
||||
$this->macros[$name] = $macro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the form action method.
|
||||
*
|
||||
@@ -984,23 +968,4 @@ class FormBuilder {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically handle calls to the form builder.
|
||||
*
|
||||
* @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.");
|
||||
}
|
||||
|
||||
}
|
||||
+3
-38
@@ -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.");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user