Bläddra i källkod

Extract method getErrorsWithoutType() from getErrors()

Visman 4 år sedan
förälder
incheckning
39b1ba5998
2 ändrade filer med 16 tillägg och 12 borttagningar
  1. 14 10
      app/Core/Validator.php
  2. 2 2
      app/Models/Pages/Auth.php

+ 14 - 10
app/Core/Validator.php

@@ -429,18 +429,22 @@ class Validator
     /**
      * Возращает массив ошибок
      */
-    public function getErrors(bool $withoutType = false): array
+    public function getErrors(): array
     {
-        if ($withoutType) {
-            $result = [];
-            \array_walk_recursive($this->errors, function ($item) use (&$result) {
-                $result[] = $item;
-            });
+        return $this->errors;
+    }
 
-            return $result;
-        } else {
-            return $this->errors;
-        }
+    /**
+     * Возращает массив ошибок без разделения на типы
+     */
+    public function getErrorsWithoutType(): array
+    {
+        $result = [];
+        \array_walk_recursive($this->errors, function ($item) use (&$result) {
+            $result[] = $item;
+        });
+
+        return $result;
     }
 
     /**

+ 2 - 2
app/Models/Pages/Auth.php

@@ -229,7 +229,7 @@ class Auth extends Page
             $isValid = $v->validation($_POST, true);
             $context = [
                 'user'    => $this->user->fLog(), // ???? Guest only?
-                'errors'  => $v->getErrors(true),
+                'errors'  => $v->getErrorsWithoutType(),
                 'form'    => $v->getData(false, ['token']),
                 'headers' => true,
             ];
@@ -291,7 +291,7 @@ class Auth extends Page
                 }
 
                 if (! $isSent) {
-                    $context['errors'] = $v->getErrors(true);
+                    $context['errors'] = $v->getErrorsWithoutType();
 
                     $this->c->Log->warning('Passphrase reset: email form, fail', $context);
                 }