@@ -92,9 +92,8 @@ public function isValid(): bool
9292 if (! $ this ->hasElement ('CSRFToken ' )) {
9393 return true ;
9494 }
95- $ csrf = $ this ->getElement ('CSRFToken ' );
9695
97- return $ csrf ->isValid ();
96+ return $ this -> getElement ( ' CSRFToken ' ) ->isValid ();
9897 }
9998
10099 return parent ::isValid ();
@@ -138,11 +137,7 @@ public function setAllowDeletion(bool $allowDeletion = true): static
138137 */
139138 public function allowDeletion (): bool
140139 {
141- if ($ this ->isCreateForm ()) {
142- return false ;
143- }
144-
145- return $ this ->allowDeletion ;
140+ return ! $ this ->isCreateForm () && $ this ->allowDeletion ;
146141 }
147142
148143 /**
@@ -178,11 +173,7 @@ public function setAllowRename(bool $allowRename = true): static
178173 */
179174 public function allowRename (): bool
180175 {
181- if ($ this ->isCreateForm ()) {
182- return false ;
183- }
184-
185- return $ this ->allowRename ;
176+ return ! $ this ->isCreateForm () && $ this ->allowRename ;
186177 }
187178
188179 /**
@@ -288,11 +279,7 @@ protected function addSectionNameElement(array $params = []): void
288279 $ params ['ignore ' ] = true ;
289280 $ params ['label ' ] ??= $ this ->translate ('Name ' );
290281 $ params ['validators ' ][] = new CallbackValidator (function ($ value , CallbackValidator $ validator ) {
291- if (Str::isEmpty ($ value )) {
292- return true ;
293- }
294-
295- if ($ value === $ this ->section ) {
282+ if (Str::isEmpty ($ value ) || $ value === $ this ->section ) {
296283 return true ;
297284 }
298285
@@ -309,11 +296,7 @@ protected function addSectionNameElement(array $params = []): void
309296
310297 protected function getIniKeyFromName (string $ name ): ?array
311298 {
312- if ($ this ->section === null ) {
313- return null ;
314- }
315-
316- return [$ this ->section , $ name ];
299+ return $ this ->section === null ? null : [$ this ->section , $ name ];
317300 }
318301
319302 protected function onSuccess (): void
@@ -407,19 +390,18 @@ protected function shouldRename(): bool
407390
408391 protected function save (): void
409392 {
393+ $ configSection = $ this ->config ->getSection ($ this ->section );
410394 foreach ($ this ->getValues () as $ element => $ value ) {
411395 if (Str::isEmpty ($ value ) && $ this ->shouldRevertIfEmpty ($ element )) {
412396 $ value = $ this ->config ->get ($ this ->section , $ element );
413397 }
414- $ configSection = $ this ->config ->getSection ($ this ->section );
415398 if (Str::isEmpty ($ value )) {
416399 unset($ configSection [$ element ]);
417400 } else {
418401 $ configSection ->$ element = $ value ;
419402 }
420- $ this ->config ->setSection ($ this ->section , $ configSection );
421403 }
422-
404+ $ this -> config -> setSection ( $ this -> section , $ configSection );
423405 $ this ->config ->saveIni ();
424406 }
425407}
0 commit comments