Created
July 15, 2019 16:34
-
-
Save mentisy/6643e8c8109239e05bab9993aa7b9667 to your computer and use it in GitHub Desktop.
CakePHP: Output entity errors in CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Command\Helper; | |
use Cake\Console\Helper; | |
class ErrorHelper extends Helper { | |
/** | |
* @param array $args | |
*/ | |
public function output($args): void | |
{ | |
$this->_io->err('Errors:'); | |
$errors_table[] = ['Field', 'Rule', 'Message']; | |
foreach($args as $field => $errors) { | |
foreach($errors as $rule => $message) { | |
$errors_table[] = [$field, $rule, $message]; | |
} | |
} | |
$this->_io->helper('Table')->output($errors_table); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment