Minor peer review

This commit is contained in:
Samuel Georges 2018-08-21 13:24:59 +10:00
parent 8383466508
commit bf841b4340
2 changed files with 12 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<?php namespace Backend\FormWidgets; <?php namespace Backend\FormWidgets;
use Backend\Classes\FormWidgetBase;
use Lang; use Lang;
use Backend\Classes\FormWidgetBase;
use ApplicationException; use ApplicationException;
/** /**
@ -80,10 +80,10 @@ class ColorPicker extends FormWidgetBase
{ {
$this->vars['name'] = $this->getFieldName(); $this->vars['name'] = $this->getFieldName();
$this->vars['value'] = $value = $this->getLoadValue(); $this->vars['value'] = $value = $this->getLoadValue();
$this->vars['availableColors'] = $this->getAvailableColors(); $this->vars['availableColors'] = $availableColors = $this->getAvailableColors();
$this->vars['allowEmpty'] = $this->allowEmpty; $this->vars['allowEmpty'] = $this->allowEmpty;
$this->vars['showAlpha'] = $this->showAlpha; $this->vars['showAlpha'] = $this->showAlpha;
$this->vars['isCustomColor'] = !in_array($value, $this->vars['availableColors']); $this->vars['isCustomColor'] = !in_array($value, $availableColors);
} }
/** /**
@ -93,11 +93,13 @@ class ColorPicker extends FormWidgetBase
*/ */
protected function getAvailableColors() protected function getAvailableColors()
{ {
if (is_array($this->availableColors)) { $availableColors = $this->availableColors;
return $this->availableColors; if (is_array($availableColors)) {
} elseif (is_string($this->availableColors) && !empty($this->availableColors)) { return $availableColors;
if ($this->model->methodExists($this->availableColors)) { }
return $this->availableColors = $this->model->{$this->availableColors}( elseif (is_string($availableColors) && !empty($availableColors)) {
if ($this->model->methodExists($availableColors)) {
return $this->availableColors = $this->model->{$availableColors}(
$this->formField->fieldName, $this->formField->fieldName,
$this->formField->value, $this->formField->value,
$this->formField->config $this->formField->config
@ -105,7 +107,7 @@ class ColorPicker extends FormWidgetBase
} else { } else {
throw new ApplicationException(Lang::get('backend::lang.field.colors_method_not_exists', [ throw new ApplicationException(Lang::get('backend::lang.field.colors_method_not_exists', [
'model' => get_class($this->model), 'model' => get_class($this->model),
'method' => $this->availableColors, 'method' => $availableColors,
'field' => $this->formField->fieldName 'field' => $this->formField->fieldName
])); ]));
} }

View File

@ -537,7 +537,7 @@ class PluginManager
return; return;
} }
$disabled = Db::table('system_plugin_versions')->where('is_disabled', '1')->lists('code'); $disabled = Db::table('system_plugin_versions')->where('is_disabled', 1)->lists('code');
foreach ($disabled as $code) { foreach ($disabled as $code) {
$this->disabledPlugins[$code] = true; $this->disabledPlugins[$code] = true;