Skip to content

Commit bf39d82

Browse files
authored
Merge pull request #5681 from Laravel-Backpack/poc-user-special-header-to-escape-message
dont escape when developer error header is present
2 parents c2e22e4 + 55cdcc0 commit bf39d82

26 files changed

+42
-39
lines changed

src/app/Exceptions/BackpackProRequiredException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public function render($request)
2020
break;
2121
}
2222

23-
return abort(500, $this->getMessage());
23+
return abort(500, $this->getMessage(), ['developer-error-exception']);
2424
}
2525
}

src/app/Library/CrudPanel/CrudButton.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public function position($position)
184184
break;
185185

186186
default:
187-
abort(500, "Unknown button position - please use 'beginning' or 'end'.");
187+
abort(500, "Unknown button position - please use 'beginning' or 'end'.", ['developer-error-exception']);
188188
}
189189

190190
return $this;
@@ -314,7 +314,7 @@ public function getHtml($entry = null)
314314
return view($button->getFinalViewPath(), compact('button', 'crud', 'entry'));
315315
}
316316

317-
abort(500, 'Unknown button type');
317+
abort(500, 'Unknown button type', ['developer-error-exception']);
318318
}
319319

320320
/**
@@ -342,7 +342,7 @@ private function getFinalViewPath()
342342
}
343343
}
344344

345-
abort(500, 'Button view and fallbacks do not exist for '.$this->name.' button.');
345+
abort(500, 'Button view and fallbacks do not exist for '.$this->name.' button.', ['developer-error-exception']);
346346
}
347347

348348
/**

src/app/Library/CrudPanel/CrudColumn.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static function name($name)
8888
public function key(string $key)
8989
{
9090
if (! isset($this->attributes['name'])) {
91-
abort(500, 'Column name must be defined before changing the key.');
91+
abort(500, 'Column name must be defined before changing the key.', ['developer-error-exception']);
9292
}
9393

9494
$columns = $this->crud()->columns();

src/app/Library/CrudPanel/CrudField.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CrudField
4646
public function __construct($nameOrDefinitionArray)
4747
{
4848
if (empty($nameOrDefinitionArray)) {
49-
abort(500, 'Field name can\'t be empty.');
49+
abort(500, 'Field name can\'t be empty.', ['developer-error-exception']);
5050
}
5151

5252
if (is_array($nameOrDefinitionArray)) {
@@ -57,7 +57,7 @@ public function __construct($nameOrDefinitionArray)
5757
}
5858

5959
if (is_array($name)) {
60-
abort(500, 'Field name can\'t be an array. It should be a string. Error in field: '.json_encode($name));
60+
abort(500, 'Field name can\'t be an array. It should be a string. Error in field: '.json_encode($name), ['developer-error-exception']);
6161
}
6262

6363
$field = $this->crud()->firstFieldWhere('name', $name);
@@ -325,7 +325,7 @@ public function morphTypeField(array $configs)
325325
$morphField = $this->crud()->fields()[$this->attributes['name']];
326326

327327
if (empty($morphField) || ($morphField['relation_type'] ?? '') !== 'MorphTo') {
328-
throw new \Exception('Trying to configure the morphType on a non-morphTo field. Check if field and relation name matches.');
328+
abort(500, 'Trying to configure the morphType on a non-morphTo field. Check if field and relation name matches.', ['developer-error-exception']);
329329
}
330330
[$morphTypeField, $morphIdField] = $morphField['subfields'];
331331

@@ -351,7 +351,7 @@ public function morphIdField(array $configs)
351351
$morphField = $this->crud()->fields()[$this->attributes['name']];
352352

353353
if (empty($morphField) || ($morphField['relation_type'] ?? '') !== 'MorphTo') {
354-
throw new \Exception('Trying to configure the morphType on a non-morphTo field. Check if field and relation name matches.');
354+
abort(500, 'Trying to configure the morphType on a non-morphTo field. Check if field and relation name matches.', ['developer-error-exception']);
355355
}
356356

357357
[$morphTypeField, $morphIdField] = $morphField['subfields'];

src/app/Library/CrudPanel/CrudFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ private function applyDefaultLogic($name, $operator, $input = null)
558558
break;
559559

560560
default:
561-
abort(500, 'Unknown filter operator.');
561+
abort(500, 'Unknown filter operator.', ['developer-error-exception']);
562562
break;
563563
}
564564
}

src/app/Library/CrudPanel/Traits/Buttons.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function orderButtons(string $stack, array $order)
3838
// we parse the ordered buttons
3939
collect($order)->each(function ($btnKey) use ($newButtons, $stackButtons) {
4040
if (! $button = $stackButtons->where('name', $btnKey)->first()) {
41-
abort(500, 'Button name [«'.$btnKey.'»] not found.');
41+
abort(500, 'Button name [«'.$btnKey.'»] not found.', ['developer-error-exception']);
4242
}
4343
$newButtons->push($button);
4444
});
@@ -117,7 +117,7 @@ public function modifyButton($name, $modifications = null)
117117
$button = $this->buttons()->firstWhere('name', $name);
118118

119119
if (! $button) {
120-
abort(500, 'CRUD Button "'.$name.'" not found. Please ensure the button exists before you modify it.');
120+
abort(500, 'CRUD Button "'.$name.'" not found. Please ensure the button exists before you modify it.', ['developer-error-exception']);
121121
}
122122

123123
if (is_array($modifications)) {

src/app/Library/CrudPanel/Traits/Fields.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ public function getStrippedSaveRequest($request)
475475
if (is_string($setting) && class_exists($setting)) {
476476
$setting = new $setting();
477477

478-
return is_callable($setting) ? $setting($request) : abort(500, get_class($setting).' is not invokable.');
478+
return is_callable($setting) ? $setting($request) : abort(500, get_class($setting).' is not invokable.', ['developer-error-exception']);
479479
}
480480

481481
return $request->only($this->getAllFieldNames());

src/app/Library/CrudPanel/Traits/FieldsProtectedMethods.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,19 @@ public function overwriteFieldNamesFromDotNotationToArray($fields)
108108
protected function makeSureFieldHasName($field)
109109
{
110110
if (empty($field)) {
111-
abort(500, 'Field name can\'t be empty');
111+
abort(500, 'Field name can\'t be empty', ['developer-error-exception']);
112112
}
113113

114114
if (is_string($field)) {
115115
return ['name' => Str::replace(' ', '', $field)];
116116
}
117117

118118
if (is_array($field) && ! isset($field['name'])) {
119-
abort(500, 'All fields must have their name defined');
119+
abort(500, 'All fields must have their name defined', ['developer-error-exception']);
120120
}
121121

122122
if (is_array($field['name'])) {
123-
abort(500, 'Field name can\'t be an array. It should be a string. Error in field: '.json_encode($field['name']));
123+
abort(500, 'Field name can\'t be an array. It should be a string. Error in field: '.json_encode($field['name']), ['developer-error-exception']);
124124
}
125125

126126
$field['name'] = Str::replace(' ', '', $field['name']);
@@ -265,12 +265,12 @@ protected function makeSureSubfieldsHaveNecessaryAttributes($field)
265265
}
266266

267267
if (! is_multidimensional_array($field['subfields'], true)) {
268-
abort(500, 'Subfields of «'.$field['name'].'» are malformed. Make sure you provide an array of subfields.');
268+
abort(500, 'Subfields of «'.$field['name'].'» are malformed. Make sure you provide an array of subfields.', ['developer-error-exception']);
269269
}
270270

271271
foreach ($field['subfields'] as $key => $subfield) {
272272
if (empty($subfield) || ! isset($subfield['name'])) {
273-
abort(500, 'A subfield of «'.$field['name'].'» is malformed. Subfield attribute name can\'t be empty.');
273+
abort(500, 'A subfield of «'.$field['name'].'» is malformed. Subfield attribute name can\'t be empty.', ['developer-error-exception']);
274274
}
275275

276276
// make sure the field definition is an array

src/app/Library/CrudPanel/Traits/Filters.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ protected function addFilterToCollection($options, $values = false, $filterLogic
7373

7474
// check if another filter with the same name exists
7575
if (! isset($options['name'])) {
76-
abort(500, 'All your filters need names.');
76+
abort(500, 'All your filters need names.', ['developer-error-exception']);
7777
}
7878

7979
if ($this->filters()->contains('name', $options['name'])) {
80-
abort(500, "Sorry, you can't have two filters with the same name.");
80+
abort(500, "Sorry, you can't have two filters with the same name.", ['developer-error-exception']);
8181
}
8282

8383
// add a new filter to the interface
@@ -168,7 +168,7 @@ public function modifyFilter($name, $modifications)
168168
$filter = $this->filters()->firstWhere('name', $name);
169169

170170
if (! $filter) {
171-
abort(500, 'CRUD Filter "'.$name.'" not found. Please check the filter exists before you modify it.');
171+
abort(500, 'CRUD Filter "'.$name.'" not found. Please check the filter exists before you modify it.', ['developer-error-exception']);
172172
}
173173

174174
if (is_array($modifications)) {

src/app/Library/CrudPanel/Traits/Macroable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait Macroable
2121
public static function macro($name, $macro)
2222
{
2323
if (method_exists(new static(), $name)) {
24-
abort(500, "Cannot register '$name' macro. '$name()' already exists on ".get_called_class());
24+
abort(500, "Cannot register '$name' macro. '$name()' already exists on ".get_called_class(), ['developer-error-exception']);
2525
}
2626

2727
static::parentMacro($name, $macro);

0 commit comments

Comments
 (0)