From 68dfedc20b316fc8e6e1623792b37f18125b42b0 Mon Sep 17 00:00:00 2001 From: crynobone Date: Sun, 13 Sep 2015 14:05:20 +0800 Subject: [PATCH 1/5] Add `Orchestra\Html\HtmlBuilder::attributable()`. Signed-off-by: crynobone --- src/HtmlBuilder.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index 9cca3aa..62de71c 100644 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -57,6 +57,20 @@ public function raw($value) return new Expression($value); } + /** + * Build a list of HTML attributes from one or two array and generate + * HTML attributes. + * + * @param array $attributes + * @param array $defaults + * + * @return string + */ + public function attributable(array $attributes, array $defaults = []) + { + return $this->attributes($this->decorate($attributes, $defaults)); + } + /** * Build a list of HTML attributes from one or two array. * @@ -88,8 +102,8 @@ protected function buildClassDecorate(array $attributes, array $defaults = []) { // Special consideration to class, where we need to merge both string // from $attributes and $defaults, then take union of both. - $default = Arr::get($defaults, 'class', ''); - $attribute = Arr::get($attributes, 'class', ''); + $default = isset($defaults['class'] ? $defaults['class'] : ''; + $attribute = isset($attributes['class'] ? $attributes['class'] : ''; $classes = explode(' ', trim($default.' '.$attribute)); $current = array_unique($classes); From db2d483d67482b6a86ef373a2c03968470bf6908 Mon Sep 17 00:00:00 2001 From: crynobone Date: Sun, 13 Sep 2015 14:40:31 +0800 Subject: [PATCH 2/5] Fixes invalid code and improves CS. Signed-off-by: crynobone --- src/HtmlBuilder.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index 62de71c..ef2937e 100644 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -2,7 +2,6 @@ use BadMethodCallException; use Illuminate\Support\Str; -use Illuminate\Support\Arr; use Orchestra\Support\Expression; use Orchestra\Html\Support\HtmlBuilder as BaseHtmlBuilder; @@ -102,8 +101,8 @@ protected function buildClassDecorate(array $attributes, array $defaults = []) { // Special consideration to class, where we need to merge both string // from $attributes and $defaults, then take union of both. - $default = isset($defaults['class'] ? $defaults['class'] : ''; - $attribute = isset($attributes['class'] ? $attributes['class'] : ''; + $default = isset($defaults['class']) ? $defaults['class'] : ''; + $attribute = isset($attributes['class']) ? $attributes['class'] : ''; $classes = explode(' ', trim($default.' '.$attribute)); $current = array_unique($classes); From 6477cdcf504d1dd3a3825a02957f16c0c1135bf4 Mon Sep 17 00:00:00 2001 From: crynobone Date: Mon, 14 Sep 2015 07:39:55 +0800 Subject: [PATCH 3/5] Add .editorconfig Signed-off-by: crynobone --- .editorconfig | 13 +++++++++++++ .gitattributes | 25 +++++++++++++------------ 2 files changed, 26 insertions(+), 12 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ed1247a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index e876b8d..7caf80d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,15 +1,16 @@ * text=auto # Ignore following folder/file. -/build export-ignore -/docs export-ignore -/tests export-ignore -/.coveralls.yml export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.php_cs export-ignore -/.scrutinizer.yml export-ignore -/.travis.yml export-ignore -/phpunit.xml export-ignore -/LICENSE export-ignore -/README.md export-ignore +/build export-ignore +/docs export-ignore +/tests export-ignore +/.coveralls.yml export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php_cs export-ignore +/.scrutinizer.yml export-ignore +/.travis.yml export-ignore +/phpunit.xml export-ignore +/LICENSE export-ignore +/README.md export-ignore From eef4e97ef1ba145e3cef1d05d181e2dcdaf9c9dc Mon Sep 17 00:00:00 2001 From: crynobone Date: Mon, 14 Sep 2015 07:53:09 +0800 Subject: [PATCH 4/5] Improves CS. Signed-off-by: crynobone --- src/Table/Grid.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Table/Grid.php b/src/Table/Grid.php index b8da1ba..c35c663 100644 --- a/src/Table/Grid.php +++ b/src/Table/Grid.php @@ -383,7 +383,7 @@ protected function buildRowsFromModel($model) } elseif (is_array($model)) { $this->setRowsData($model); } else { - throw new InvalidArgumentException("Unable to convert \$model to array."); + throw new InvalidArgumentException('Unable to convert $model to array.'); } } @@ -424,7 +424,7 @@ protected function resolveQueryBuilderFromModel() $model = $this->model; if (! $this->isQueryBuilder($model)) { - throw new InvalidArgumentException("Unable to load Query Builder from \$model"); + throw new InvalidArgumentException('Unable to load Query Builder from $model'); } return $model; From b0948bf6e7994c31fec01d3b978bd1c366ea1bec Mon Sep 17 00:00:00 2001 From: crynobone Date: Mon, 14 Sep 2015 19:23:49 +0800 Subject: [PATCH 5/5] v3.0.2 * Add `Orchestra\Html\HtmlBuilder::attributable()` method. Signed-off-by: crynobone --- docs/changes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changes.md b/docs/changes.md index 33f6375..a6c6fee 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -5,6 +5,10 @@ title: HTML Change Log ## Version 3.0 {#v3-0} +### v3.0.2 {#v3-0-2} + +* Add `Orchestra\Html\HtmlBuilder::attributable()` method. + ### v3.0.1 {#v3-0-1} * Add `Form::number()` and `Form::date()` helpers.